In matplotlib when we plot with errorbars and use "legend" to show the legends, there could be some trouble that the legends are proper for the lines with error bars. Here is a trick for a clean display in such cases: use the kwargs to set the line label. For example,
figure()
errorbar(x1, y1, xerr, fmt='o',ecolor='g',label='legend1', markersize=12)
plot(x2,y2,label='legend3')
# to put legend at the optimal location
legend(loc=0)
Aucun commentaire:
Enregistrer un commentaire