I might do something wrong (actually I most certainly do) but I do not know, why the xticks in my barplot do not align with the axis. Here is my code:
from matplotlib import pyplot as plt
cond1 = '455 nm'
cond2 = 'Dark'
temp = nodubs[nodubs.group == cond1]
bar1 = temp.value
yerr1 = [np.zeros(len(temp.stdev)),temp.stdev]
temp = nodubs[nodubs.group == cond2]
bar2 = temp.value
yerr2 = [np.zeros(len(temp.stdev)),temp.stdev]
r1 = np.arange(len(bar1))
bwidth = 0.3
r2 = [x + bwidth for x in r1]
plt.bar(r1, bar1, width = bwidth, color = 'blue', edgecolor = 'black', capsize=2, label=cond1, yerr = yerr1)
plt.bar(r2, bar2, width = bwidth, color = 'cyan', edgecolor = 'black', capsize=2, label=cond2, yerr = yerr2)
plt.xticks(r1, temp.condition, rotation=45)
plt.ylabel('SEAP/(U L^-1)')
plt.legend()
#plt.ylim((0,0.7))
plt.savefig('figure.png', dpi=600,bbox_inches='tight')
plt.show()
And here a picture of the plot:
In this example r1 is: [ 0 1 2 3 4 5 6 7 8 9 10 11]
and temp.condition:
7 p.....(s)
15 p........ + p.....
23 p........ + p.....
31 p........ + p..... + p.....
39 p........ + p..... + p.....
47 p........ + p..... + p.....
55 p........ + p..... + p.....
63 p........ + p..... + p.....
71 p........
79 p........ + p.....
87 p........ + p..... + p.....
95 p........ + p............. + p.....
Name: condition, dtype: object
As plt.xticks() and plt.bar() receive the same location parameter, shouldn't they align with each other?
Thanks for any help Carroll