Alan G Isaac, on 2010-10-27 18:31, wrote: > Here is another example of unwanted text clipping > in the gallery: > http://matplotlib.sourceforge.net/examples/api/two_scales.html#api-two-scales > (Both y axis labels are clipped.) > > I also think the example would be more complete if it > 1. set a 270 degree rotation on the second ylabel, and > 2. showed how to make a single legend for the two lines > > Btw, how *does* one best do 2?
I don't know if it's best, but legend can take a list of objects and labels, so you can just grab all of the objects from the twin, and put them all in one legend: def onelegend_twinaxes(axis,twin): #make a joint axis legend lines = twin.get_lines() lines.extend(axis.get_lines()) labels = [l.get_label() for l in lines] return axis.legend(lines, labels) Here's a picture of what that looks like (thought I did some other prettifications). <http://pirsquared.org/images/twinaxes_onelegend.png> I wrote this in a solution set for a class I'm TAing this semester, so you can look at the whole thing here, if you'd like. the file is part of the solutions for Lab #1, it's called lab1.py (but actually links to lab1.txt): <http://redwood.berkeley.edu/wiki/VS265:_Homework_assignments> -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users