Python Forum

Full Version: How to create custom error bars in matplotlib.pyplot?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
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