Is it possible to split up a single big legend into multiple (usually 2) smaller ones.
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0, label="Graph1")
grid(True)
s = sin(4*pi*t)
plot(t, s, color='r',linewidth=1.0, label="Graph2")
legend(loc='lower left')
show()
I would like to split the legend into two and place them where white space is available.
I got the answer from http://matplotlib.sourceforge.net/users/plotting/examples/simple_legend02.py
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
p1, = plot(t, s, linewidth=1.0, label="Graph1")
grid(True)
s = sin(4*pi*t)
p2, = plot(t, s, color='r',linewidth=1.0, label="Graph2")
l1 = legend([p1], ["Graph1"], loc=1)
l2 = legend([p2], ["Graph2"], loc=4)
gca().add_artist(l1)
show()
Here, the only drawback is I have to give the labelname twice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With