matplotlib histograms and labels
19,334
You have to include a legend call:
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()
Related videos on Youtube
Author by
nancyh
Studying for a Masters in Astronomy I am just learning to use python .
Updated on June 04, 2022Comments
-
nancyh about 2 years
I am plotting a histogram with two sets of data and want to include a key. I have found an example that uses the label command, but when I use this it doesn't work. The histogram appears correctly, but there is no key. My code is.
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()
Any suggestions?
-
nancyh about 11 yearsThanks, I completely missed that in the example :)