I have to prepare a graph and I always wanted to learn Phyton so that is what I'm trying to do. In the end I want to get something like this: Inspiration for the graph I want to create So far I got to this point: Graph I created
However I don't like it. I would like the categories on x axis to be more defined (?). Something like this: Beautiful representation of what i want
My code looks like this:
DW1 = pd.read_csv('DW1.csv', index_col=0, sep=';')
DW1.head()
fig, ax = plt.subplots()
ax.bar(DW1.treat, DW1.mean_s, edgecolor = 'black', color = '#4daf4a')
ax.bar(DW1.treat, -DW1.mean_r, edgecolor = 'black', color = '#a65628')
ax.yaxis.set_major_formatter(lambda x, pos: f'{abs(x):g}')
ax.margins(x=0)
ax.set_ylabel('Dry biomass (g)')
ax.set_xlabel('Days after treatment')
ax.set_title('Root and shoot dry biomass')
plt.errorbar(DW1.treat, DW1.mean_s, yerr = DW1.std_s,fmt='o',ecolor = 'black', color = 'NONE', capsize = 3),
plt.errorbar(DW1.treat, -DW1.mean_r, yerr = DW1.std_r,fmt='o',ecolor = 'black', color = 'NONE', capsize = 3),
ax.set_xticklabels(('Control' , 'Zn', 'Cd' '\n\n3', 'Zn+Cd',
'Control' , 'Zn', 'Cd' '\n\n7', 'Zn+Cd',
'Control' , 'Zn', 'Cd''\n\n14', 'Zn+Cd',
), minor=False, rotation=
0)
plt.show()
And here is my data: https://github.com/Kosia78/dw/blob/252650489f5e73e9ad15dbbe89c886e8b324c25d/DW1.csv
I looked around but I can't figure out how to do this. The way it is now I can of course fix it manually in InkScape but Id like to do it properly. Is there any way to salvage this? Should I do it in a completly different way? If so how should I have done it?
Thank you for your help!