3

I am new on Stack Overflow so apologize if this is a duplicate question or is vague - I am also new at Python and coding in general.

I am wanting to create an error bar graph that has unequal "error limits" on high versus low.

I will be plotting average temperature for a month, with the upper error needing to be the highest temperature of the month and the lower error needing to be the lowest temperature of the month.

I understand how to use an error bar with the errors being equal, but do not understand how to make them unequal.

A picture has been added for reference. A shortened example of the lists I will be using to graph are:

temps_avg = [46, 49, 58, 69, 73, 79, 84]
temps_high = [78, 80, 82, 88, 88, 93, 101]
temps_low = [21, 29, 25, 48, 54, 62, 70]

Bar Chart I'd Like to Duplicate but without Even Error Bars

Bar Chart I'd Like to Duplicate but without Even Error Bars

0

2 Answers 2

5

You can place the low and high error limits inside a tuple in the yerr arg of matplotlib's bar plot:

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.bar([0,1,2,3,4,5,6], temps_avg, yerr = (temps_low,temps_high))
Sign up to request clarification or add additional context in comments.

Comments

0

Looks to me you can do either of

  1. Draw upper and lower limits separately using lolims, uplims arguments (see here)
  2. Pass the y argument to errorbar so that upper and lower errors are equal, i.e. in your case y = (temps_high+temps_low)/2, this way using temp_avg only to plot line but not the errors.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.