Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 error bars with dataframe and pandas
#1
Hello everyone,

hope someone can give me an advice.

I have 3 dataframes with different values, each with time (x-values) and y values.
I calculated the average and the standard deviation for the error bars with
mean = dataframe.groupby(['time','y values']).agg({'y values':'mean'}).reset_index()
std = dataframe.groupby(['time','y values']).agg({'y values':'std'}).reset_index()
mean['err'] = std['y values']
Then I tried to plot everything with

fig, (ax1) = plt.subplots(1, 1) 
mean.plot(x='time', y='y values', style='.', color='b', legend=True, label='test', ax=ax1) 
ax1.errorbar(mean.index, mean['time'], yerr=mean['err'])
ax1.legend(loc='lower right', fancybox=True, fontsize=9)
ax1.yaxis.set_label_text("y values")  
ax1.xaxis.set_label_text("Time (h)")
ax1.set_title("test")  
But the error bars are not shown in the right way. I tried it already with mean.plot(...yerr=' '), but the same result. Someone have an idea?
Quote
#2
What are you wanting, and what are you getting?
Check Matplotlib documentation
Quote
#3
Hi,

here you find the pictures
error bars should be and actual

the first one is, how the error bars should be and the second and third how they are.
I have absolutely no idea anymore.
Quote
#4
Hard to tell, what is the shape of mean? std?
Have you tried making x and y in the errorbar call just mean and std, and no other arguments? Or mean.values and std.values and no other arguments?
Quote
#5
Found the mistake. I did
[pyhton]fig, (ax1) = plt.subplots(1, 1) ....[/[pyhton]]

and then later again
[pyhton]fig, (ax1) = plt.subplots(1, 1) ....[/[pyhton]]

Now I changes the second subplots ax1 to ax2 and everything works fine.
Thank you for your help.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Pandas DataFrame Concatenate problems Kristenl2784 1 95 Yesterday, 01:28 AM
Last Post: hussainmujtaba
  Difference of two columns in Pandas dataframe zinho 2 349 Jun-17-2020, 03:36 PM
Last Post: zinho
  error : value of a DataFrame is ambiguous Sonata 1 268 Apr-24-2020, 05:40 PM
Last Post: anbu23
  Python Pandas DataFrame Help AmericanEagle1989 1 221 Apr-12-2020, 12:37 PM
Last Post: AmericanEagle1989
  How to display percentage above the bars in bar graph? WhatsupSmiley 0 579 Mar-31-2020, 07:21 PM
Last Post: WhatsupSmiley
  How does pyplot know what was plotted by the output of pandas.DataFrame(...).cumprod( codeowl 2 245 Mar-28-2020, 08:27 AM
Last Post: j.crater
  pip install pandas ERROR pythondudu 6 6,426 Mar-26-2020, 07:49 PM
Last Post: snippsat
  Ordering of pandas DataFrame new_to_python 5 308 Mar-15-2020, 06:08 PM
Last Post: new_to_python
  Pandas dataframe merge snmmat 1 316 Mar-09-2020, 06:56 PM
Last Post: jefsummers
  Transform Facebook Graph API insights JSON to pandas dataframe usman 0 346 Mar-03-2020, 05:14 AM
Last Post: usman

Forum Jump:


Users browsing this thread: 1 Guest(s)