2013-03-21 2 views
0

y 오류가있는 여러 데이터 요소를 플롯하고 범례에 오류 막대가 포함되는 것을 원하지 않습니다. Matplotlib: Don't show errorbars in legend 그러나 나는 해결책을 발견하지 않은 :범례의 오류 막대.

p1=ax.errorbar(x,y, yerr=[ydown,yup], color='blue', fmt='s', ecolor='blue') 
p2=ax.errorbar(x1,y1, yerr=[y1down,y1up], color='black', fmt='.', ecolor='black') 
ax.legend([p1,p2],['data1','data2'], loc='upper left', numpoints=1) 

내 질문은 이전과 비슷합니다. 감사합니다. .

답변

4

범례 처리기를 수정할 수 있습니다. legend guide of matplotlib을 참조하십시오. 예를 적용하면 다음과 같이 읽을 수 있습니다.

# get handles 
handles, labels = ax.get_legend_handles_labels() 
# remove the errorbars 
handles = [h[0] for h in handles] 
# use them in the legend 
ax.legend(handles, labels, loc='upper left', numpoints=1)