I have the following little function:
def plotresults(freqs,power,prob,title,sigP):
pl.suptitle(title)
ax1 = pl.subplot(2,1,1)
ax1.axhline(y=sigP, color='r', ls='--',label='p=0.05')
pl.plot(freqs,power)
ax1.set_ylabel('Spectral Power')
ax2 = pl.subplot(2,1,2)
ax2.axhline(y=0.05, color='r', ls='--', label='p=0.05')
pl.semilogy(freqs,prob)
ax2.set_xlabel(r'Frequency (years$^{-1}$)')
ax2.set_ylabel('p-value')
pl.savefig('lsfast/figs/'+title+'.png')
pl.close()
It plots fine and draws the lines where they should be, but the line labels don't appear anywhere. What am I doing wrong? AN example of the output is attached:
The label kwarg for plot sets the label that's used by legend. To display it you can add a legend to your plot. Alternately, you might want to use annotate instead.