2013-06-06 4 views
3

두 세트의 데이터로 막대 그래프를 플롯하고 키를 포함하려고합니다. label 명령을 사용하는 예제를 발견했지만 사용하면 작동하지 않습니다. 막대 그래프가 올바르게 나타나지만 키가 없습니다. 내 코드가 있습니다.matplotlib 막대 그래프 및 레이블

H1 = <some data> 
S1 = <some other data> 

hist([H1,S1], bins=25, range=(10,30), align=('mid'), color=['green', 'orange'], label=['Actual H band', 'Actual IRAC2 band']) 
title("Actual observed magnitudes of sources in H and IRAC2") 
xlabel("Magnitude") 
ylabel("Frequency") 

show() 

의견이 있으십니까?

답변

5

당신은 전설의 호출을 포함해야한다 :

H1 = <some data> 
S1 = <some other data> 

hist([H1,S1], bins=25, range=(10,30), align=('mid'), color=['green', 'orange'], label=['Actual H band', 'Actual IRAC2 band']) 
title("Actual observed magnitudes of sources in H and IRAC2") 
xlabel("Magnitude") 
ylabel("Frequency") 
legend() 

show() 
+0

가 감사합니다, 나는 완전히 놓친을 그 예 :)에서 – nancyh

관련 문제