From: Werner F. B. <wer...@fr...> - 2005-04-08 17:23:57
|
Hi, I am just getting my feet wet with matplotlib. I like plots with the legend outside the plotting area. I found the demo which uses figlegend (thanks Andrea), this fits the bill - at least I think so. However I can't get this to work within the wxcursor_demo.py, is figlegend only available with "from pylab import *"? The other question is can I have sub-title lines, I saw that I can pass newline with title string but this uses the same font attributes, I would like a slightly smaller font and non bold etc for the second title line. Looked through the archive on gmane, but couldn't find anything. Appreciate any pointers on this. See you Werner |
From: Chris B. <Chr...@no...> - 2005-04-08 17:47:56
|
Werner F. Bruhin wrote: > However I can't get this to work within the wxcursor_demo.py, is > figlegend only available with "from pylab import *"? I'm not sure about that one, but there are a number of convenience functions that are only in pylab. If so, you have two choices: 1) Use: import pylab pylab.figlegend(...) 2) you can look at the code in pylab.figlegend, and see what it does, and make your own version. By the way, I'm on a quest to make the OO interface to matplotlib fully functional and convenient. If you want to work on it, John would probably except a patch to make a figure.legend() method. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
From: John H. <jdh...@ac...> - 2005-04-08 18:17:04
|
>>>>> "Chris" == Chris Barker <Chr...@no...> writes: Chris> By the way, I'm on a quest to make the OO interface to Chris> matplotlib fully functional and convenient. If you want to Chris> work on it, John would probably except a patch to make a Chris> figure.legend() method. pylab.figlegend is a thin wrapper to matplotlib.Figure.legend; see http://matplotlib.sf.net/matplotlib.figure.html#Figure-legend <wink> JDH |
From: Werner F. B. <wer...@fr...> - 2005-04-09 12:54:56
|
Hi John and Chris, John Hunter wrote: >>>>>>"Chris" == Chris Barker <Chr...@no...> writes: > > > Chris> By the way, I'm on a quest to make the OO interface to > Chris> matplotlib fully functional and convenient. If you want to > Chris> work on it, John would probably except a patch to make a > Chris> figure.legend() method. > > pylab.figlegend is a thin wrapper to matplotlib.Figure.legend; see > http://matplotlib.sf.net/matplotlib.figure.html#Figure-legend Got it, also don't understand why I could not get this to work yesterday - probably had crossed eyes. Thanks and best regards Werner > > <wink> > > JDH > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click |
From: Werner F. B. <wer...@fr...> - 2005-04-09 14:20:03
|
I still have a bit of a problem. This puts the legend "more or less" outside the plot. If I use "upper right" with only two lines it is o.k., however if I use e.g. "center right" then about half of the legend is still over the top of the plot. Also if I have more then 2 lines I start overlapping even when using "upper right". This is what I use (within the wxcursor_demo.py). self.figure.legend((pLine, cLine), ('Purchase', 'Consumption'), 'upper right') I would like the legend being totally outside the plot, I am o.k. with that the overall canvas would have to be a bit larger. Is there a way I can do this? BTW, I tried using "axespad = 0.02" with different values, i.e. "-0.15" puts it to the right, but half the legend isn't visable anymore. Thanks and best regards Werner Werner F. Bruhin wrote: > Hi John and Chris, > > John Hunter wrote: > >>>>>>> "Chris" == Chris Barker >>>>>>> <Chr...@no...> writes: >> >> >> >> Chris> By the way, I'm on a quest to make the OO interface to >> Chris> matplotlib fully functional and convenient. If you want to >> Chris> work on it, John would probably except a patch to make a >> Chris> figure.legend() method. >> >> pylab.figlegend is a thin wrapper to matplotlib.Figure.legend; see >> http://matplotlib.sf.net/matplotlib.figure.html#Figure-legend > > > Got it, also don't understand why I could not get this to work yesterday > - probably had crossed eyes. > > Thanks and best regards > Werner > >> >> <wink> >> >> JDH >> >> >> ------------------------------------------------------- >> SF email is sponsored by - The IT Product Guide >> Read honest & candid reviews on hundreds of IT Products from real users. >> Discover which products truly live up to the hype. Start reading now. >> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click |
From: John H. <jdh...@ac...> - 2005-04-11 14:00:57
|
>>>>> "Werner" == Werner F Bruhin <wer...@fr...> writes: Werner> I still have a bit of a problem. This puts the legend Werner> "more or less" outside the plot. If I use "upper right" Werner> with only two lines it is o.k., however if I use Werner> e.g. "center right" then about half of the legend is still Werner> over the top of the plot. I think the best approach is to use fig.add_axes rather than fig.add_subplot to create your axes. Then you can make it the exact size you want. You can also place the figure legend anywhere you want by using loc=(x,y) instead of a location string. I just noticed this was undocumented :-(. It *is* documented for the axes legend, and I'll fix the figure legend docstring for the next release. Here's a little example import pylab as p fig = p.figure() ax = fig.add_axes([0.1, 0.3, 0.4, 0.4]) lines = ax.plot([1,2,3]) fig.legend(lines, ('hi', ), loc=(0.6, 0.6)) p.show() Hope this helps, JDH |
From: Werner F. B. <wer...@fr...> - 2005-04-11 17:04:45
|
Hi John, John Hunter wrote: >>>>>>"Werner" == Werner F Bruhin <wer...@fr...> writes: > > > Werner> I still have a bit of a problem. This puts the legend > Werner> "more or less" outside the plot. If I use "upper right" > Werner> with only two lines it is o.k., however if I use > Werner> e.g. "center right" then about half of the legend is still > Werner> over the top of the plot. > > > I think the best approach is to use fig.add_axes rather than > fig.add_subplot to create your axes. Pitty that I can't have both. But I'll worry about this one when I actually do make use of the subplots. Then you can make it the exact > size you want. You can also place the figure legend anywhere you want > by using loc=(x,y) instead of a location string. I just noticed this > was undocumented :-(. You think I would have found it:) It *is* documented for the axes legend, and > I'll fix the figure legend docstring for the next release. > > Here's a little example > > import pylab as p > fig = p.figure() > ax = fig.add_axes([0.1, 0.3, 0.4, 0.4]) > > lines = ax.plot([1,2,3]) > fig.legend(lines, ('hi', ), loc=(0.6, 0.6)) > p.show() > > Hope this helps, > JDH Thanks, yes this did help! Werner > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click |
From: Werner F. B. <wer...@fr...> - 2005-04-09 13:03:38
|
The part about the sub-title got over looked, so I'll post again - anyhow it was bad from me to stick two things into one message - sorry! Is it possible to have sub-title lines, I saw that I can pass newline with title string but this uses the same font attributes, I would like a slightly smaller font and non bold etc for the second title line. Thanks for any hints. Werner |
From: Werner F. B. <wer...@fr...> - 2005-04-10 17:57:51
|
Hi All, I figured this out, just doing something along these lines does the trick for me. self.figure.text(0.5, 0.95, title, horizontalalignment='center') self.figure.text(0.5, 0.92, 'sub title', horizontalalignment='center') See you Werner Werner F. Bruhin wrote: > The part about the sub-title got over looked, so I'll post again - > anyhow it was bad from me to stick two things into one message - sorry! > > Is it possible to have sub-title lines, I saw that I can pass newline > with title string but this uses the same font attributes, I would like a > slightly smaller font and non bold etc for the second title line. > > Thanks for any hints. > Werner > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click |