Python Forum
error bars with dataframe and pandas
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?
Reply


Messages In This Thread
error bars with dataframe and pandas - by Hucky - Apr-19-2020, 10:18 PM
RE: error bars with dataframe and pandas - by Hucky - Apr-24-2020, 11:26 PM
RE: error bars with dataframe and pandas - by Hucky - Apr-27-2020, 02:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Formatting cells of a pandas dataframe into an OpenDocument ods spreadsheet Calab 1 1,037 Mar-01-2025, 04:51 AM
Last Post: Calab
  Find duplicates in a pandas dataframe list column on other rows Calab 2 2,595 Sep-18-2024, 07:38 PM
Last Post: Calab
  Find strings by index from a list of indexes in a different Pandas dataframe column Calab 3 1,858 Aug-26-2024, 04:52 PM
Last Post: Calab
  Add NER output to pandas dataframe dg3000 0 1,273 Apr-22-2024, 08:14 PM
Last Post: dg3000
  HTML Decoder pandas dataframe column mbrown009 3 2,915 Sep-29-2023, 05:56 PM
Last Post: deanhystad
  How to create a plot with line graphs and vertical bars devansing 6 4,771 Feb-28-2023, 05:38 PM
Last Post: devansing
  Use pandas to obtain cartesian product between a dataframe of int and equations? haihal 0 2,139 Jan-06-2023, 10:53 PM
Last Post: haihal
  pip install pandas ERROR pythondudu 7 43,462 May-24-2022, 06:14 AM
Last Post: Marya_475
  Pandas Dataframe Filtering based on rows mvdlm 0 2,173 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  Pandas dataframe: calculate metrics by year mcva 1 3,603 Mar-02-2022, 08:22 AM
Last Post: mcva

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020