I have a set of plots in python and want to add legends to each of them separately. I am generating the plots in a for loop and want to add the legends dynamically.
Im getting only the last legend shown. I want all 9 off them to be displayed
for q in range(1,10):
matplotlib.pylab.plot(s_A_approx, label = q)
matplotlib.pylab.legend(loc = 'upper left')
matplotlib.pylab.show()
matplotlib.pylab.hold(True)
– Guildlegend
call inside the loop? – Apterouss_A_approx
? – Turmellabel=q
tolabel=str(q)
, but after that, the plot and legend are produced as expected. Maybe see if you can provide here more of your script, like where s_A_approx comes from or an example of whats_A_approx
looks like? – Turmelfor q in range(1,10):
A = (A*A.T)**q
[U, s_A_approx, V] = numpy.linalg.svd(A)
matplotlib.pylab.plot(s_A_approx, label = str(q))
matplotlib.pylab.legend(loc = 'upper left')
matplotlib.pylab.show()
– Guild