python - Matplotlib legends in subplot -
i'm new @ matplotlib, put legends inside each 1 of subplots bellow. i've tried plt.legend didn't work.
any suggestions?
thanks in advance :-)
f, (ax1, ax2, ax3) = plt.subplots(3, sharex=true, sharey=true) ax1.plot(xtr, color='r', label='blue stars') ax2.plot(ytr, color='g') ax3.plot(ztr, color='b') ax1.set_title('2012/09/15') plt.legend([ax1, ax2, ax3],["hhz 1", "hhn", "hhe"]) plt.show()
suggestion atomh33ls:
ax1.legend("hhz 1",loc="upper right") ax2.legend("hhn",loc="upper right") ax3.legend("hhe",loc="upper right")
the legend position fixed, seems have problem strings, because each letter placed in new line.
does knows how fix it?
this should work:
ax1.plot(xtr, color='r', label='hhz 1') ax1.legend(loc="upper right") ax2.plot(xtr, color='r', label='hhn') ax2.legend(loc="upper right") ax3.plot(xtr, color='r', label='hhe') ax3.legend(loc="upper right")
Comments
Post a Comment