Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 606
Isaac Avatar asked Mar 09 '16 15:03

Isaac


1 Answers

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.

like image 124
AngelPL Avatar answered Sep 21 '22 10:09

AngelPL