I have been battling this for too long, to the point that I'm pretty sure I don't understand the implementation of twinx in matplotlib
ok I have some code
import matplotlib.pyplot as plt
data1 = [5, 6, 6, 7]
err1 = [1, 1, 1, 1]
data2 = [0.5, 0.6]
err2 = [0.01, 0.01]
label1 = ['var1', 'var2', 'var3', 'var4']
label2 = ['var5', 'var6']
If I just want to plot data 1 everything is fine.
fig, ax1 = plt.subplots()
ax1.bar(label1, data1, yerr=err1, color='red')
plt.show()
If I want to add data 2 onto a second axis I lose columns and the order is also odd.
ax1.bar(label1, data1, yerr=err1, color='red')
ax2 = ax1.twinx()
ax2.bar(label2, data2, yerr=err2, color='blue')
plt.show()
Does not give me six columns but only 4 with two of the data1 columns now missing?
Obviously Im 100% sure its my fault, but please someone put me out of this misery...


