TypeError: errorbar() got multiple values for keyword argument 'yerr'
Asked Answered
L

1

6

I am trying to plot errorbar with the array of mean values and standard deviation by python as below:

p11 = np.genfromtxt(filn1,delimiter="",usecols=0,dtype=None)
p12 = np.genfromtxt(filn3,delimiter="",usecols=0,dtype=None) 
s11 = np.genfromtxt(filn2,delimiter="",usecols=0,dtype=None)
s12 = np.genfromtxt(filn4,delimiter="",usecols=0,dtype=None)
F1= np.genfromtxt(filn6,delimiter="",usecols=0,dtype=None)
F2= np.genfromtxt(filn7,delimiter="",usecols=0,dtype=None)
yerr1 =0.5*s11
yerr2 = 0.5*s12
plt.errorbar(F1,p11,'r',yerr=yerr1,lw=3,label='Summer')
plt.errorbar(F2,p12,'b',yerr=yerr2,lw=3,label='Winter')

Here p11 and p12 are mean value arrays and s11 and s12 are corresponding standard deviation arrays. This code has worked well, but now it resulted:

TypeError: errorbar() got multiple values for keyword argument 'yerr'

Any idea or hints would be really appreciated. Isaac

Lepp answered 9/3, 2016 at 15:44 Comment(4)
What are those r and b values for?Casement
@DanielRoseman 'r' and 'b' are for color.Lepp
Well, matplotlib.pyplot.errorbar does not appear to have color as the third positional argument: see the docs.Casement
@DanielRoseman Yes Daniel Roseman, you are totally right. I apologize for my careless question.Lepp
B
7

I think the third parameter for plt.errorbar has to be the yerr, but in your case you are using the format. Try to specify the format with 'fmt'.

plt.errorbar(F1,p11,fmt='r',yerr=yerr1,lw=3,label='Summer')
plt.errorbar(F2,p12,fmt='b',yerr=yerr2,lw=3,label='Winter')

My advice is always use the parameter names, so it is easy to read the code and debugging.

Billiton answered 17/10, 2017 at 18:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.