Python Forum
How to create custom error bars in matplotlib.pyplot?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create custom error bars in matplotlib.pyplot?
#1
I have created a list of average monthly temperatures and the high and low temperatures for each month. I am being asked to create a bar graph for each month's average temperature, and then add error bars where the upper limit of the error bar is the highest temperature that month, and the lower limit of the error bar is the lowest temperature of that month. The graph I made is below, but how do I add vertical error bars where I specify the upper and lower limits of it? I know how to use yerror but from what I have seen that only produces symmetrical error bars whereas mine would be different lengths above and below the graph.
plt.bar(list_of_months, average_temps)
Reply
#2
figured it out.
I made two new lists, the upper limit list was the high minus the average, and the other lower list was the average minus the low.
asymmetric_error_bars=[lower_limit_list, upper_limit_list]
plt.bar(dates, average_temp, yerr=asymmetric_error_bars
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Issues with matplotlib.pyplot schniefen 2 2,251 Apr-19-2019, 11:51 AM
Last Post: schniefen
  How to customize x axis in matplotlib.pyplot for a scatter plot? wlsa 9 8,117 Nov-10-2018, 01:32 AM
Last Post: wlsa
  Please help with Create Custom class Robot(): TheRealOne 5 3,130 Nov-05-2018, 03:41 AM
Last Post: ichabod801
  Pyplot line color and spacing/padding metalray 0 2,674 May-26-2017, 08:39 AM
Last Post: metalray

Forum Jump:

User Panel Messages

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