Skip to content Skip to sidebar Skip to footer

Python Matplotlib - Errorbar None Values In Series

I was trying to plot a series with error bars. The series may contain None values. When not using the errors - the series is plotted with no error. When trying to plot with the err

Solution 1:

Try using NaN rather than "None".

x = [10.4, 11.12,11.3,float('NaN'), 10.2,11.3]
y = [0.3, 1.2, 0.7, float('NaN'), 1.1, 0.4]
y_err = [0.01, 0.04, 0.07, float('NaN'), 0.01, 0.05] 
plt.plot(x,y, 'o', color='r')
plt.errorbar(x,y,yerr=y_err)

Assigning a variable NaN in python without numpy

Post a Comment for "Python Matplotlib - Errorbar None Values In Series"