graph - How do I remove error bars from legend (matplotlib)? -


i plotting 4 sets of data on same graph, each set has different y values depending on variable p. in legend end 8 different element, 4 each different set of data , 4 error bars, shown here: http://i.stack.imgur.com/9zovm.png

a simplified version of code shown below:

import matplotlib.pyplot plt  plt.plot(x1, y1, c='b', marker='o', label='p=0', markersize=4) plt.plot(x2, y2, c='g', marker='+', label='p=1', markersize=4) plt.plot(x3, y3, c='r', marker='*', label='p=2', markersize=4) plt.plot(x4, y4, c='k', marker='s', label='p=3', markersize=4) plt.errorbar(x1, y1, yerr=yerr0, color='b') plt.errorbar(x2, y2, yerr=yerr1, color='g') plt.errorbar(x3, y3, yerr=yerr2, color='r') plt.errorbar(x4, y4, yerr=yerr3, color='k') plt.ylabel("different y") plt.xlabel("different x") plt.xlim(xmin=0, xmax=maxx) plt.suptitle("different y vs different x", fontsize=14, fontweight='bold') plt.legend(loc='upper right', numpoints=1) plt.show() 

i want markers data in legend, how remove ones error bars?

if assign lines variables when create them can tell .legend() lines show:

line1, = plt.plot(x1, y1, c='b', marker='o', label='p=0', markersize=4) line2, = ... line3, = ... line4, = ... 

and draw legend with:

plt.legend((line1, line2, line3, line4), loc='upper right', numpoints=1) 

and change labels each line can pass tuple new labels:

plt.legend((line1, line2, line3, line4), ('label1', 'label2', 'label3', 'label4'), loc='upper right', numpoints=1) 

hopefully give want.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -