In my case, this is the current code:
import matplotlib.pyplot as plt
x=['A','B','C']
y=[1,3,4]
z=[3,4,2]
yerror=[0.1,0.2,0.1]
zerror=[0.2,0.1,0.1]
ax = plt.subplot(111)
ax.bar(x, y, yerr=yerror, width=0.4, color='b', align='center')
ax.bar(x, z, yerr=zerror, width=0.4, color='g', align='center')
plt.gcf().set_size_inches(15, 8)
plt.show()
The resulting plot has both y and z bars plotted on top of the other. When checking other similar questions, to solve this problem usually the first parameter in ax.bar has a value added to it, or the axis are organized differently. But it doesn't seem to work on my case. Is there a simple solution to it?
CodePudding user response:
The example here shows a method of shifting the bars while maintaining text labels on the x-axis: https://matplotlib.org/stable/gallery/lines_bars_and_markers/barchart.html