I have data in a csv file structured like so:
Subject group Result1 Result2... ResultN
101 a .5 .1 .2
103 b .1 .2 .5
104 b .2 .3 .4
mean_a a .5 .1 .2
mean_b b .1 .6 .4
ste_a a .05 .02 .03
ste_b b .01 .05 .04
I just want to end up with a bar plot, grouped by the Result, of the mean rows' values for each group, with the stes as the error bars. Unfortunately, I'm having trouble doing so. I can convert the dataframe to two separate dataframes, one for means and one for stes, like this:
a b
Result1 .5 .1
Result2 .1 .6
However, I cannot figure out how to plot the second dataframe of stes as error bars, and my method seems overly complicated, so I was wondering if anyone knows of a simpler way to do this and, if not, how to use the one dataframe to plot error bars for the other dataframe.
It is quite easy, just pass your error data to yerr
argument the same as you will do in matplotlib
.
DF=pd.DataFrame({'a':[.5,.1],'b':[.1,.6]})
DF.index=['Result1','Result2']
DF.plot(kind='bar',yerr=DF.b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With