From: Charles T. <ct...@ma...> - 2003-09-29 23:44:36
Attachments:
legendplot.py
|
I couldn't see any way to do legends, so I hacked together a routine that worked for me. However, I don't know how to handle fonts properly (ie, find out how much plotting space they really take up), so someone might want to fix the two lines marked "#Hack" and maybe the related row spacing. Here's a simple demo that includes the legend() function. Attached, I hope. -C -- Charles R. Twardy Monash University, School of CSSE ctwardy at alumni indiana edu +61(3) 9905 5823 (w) 5146 (fax) ~^~ "eloquence ought to be banish'd out of all civil Societies as a thing fatal to Peace and good Manners..." ~Sprat 1667 |
From: Kuzminski, S. R <SKu...@fa...> - 2004-03-10 19:34:51
|
Is there a way for the legend to be outside of the axis? Perhaps rendered separately. =20 thanks, S |
From: John H. <jdh...@ac...> - 2004-03-10 20:04:24
|
>>>>> "Kuzminski," == Kuzminski, Stefan R <SKu...@fa...> writes: Kuzminski,> Is there a way for the legend to be outside of the Kuzminski,> axis? Perhaps rendered separately. The current implementation of legend takes an axes instance in it's constructor. I just did a read through of that code and it would be trivial to factor it out. The only thing the legend uses that instance for is the background color! You could have a figure legend much in the same way you have figure text. I can probably do it in 20 minutes. When I get 20 minutes, I'll send you a patch.... JDH |
From: Michael P. M. <mo...@jp...> - 2006-03-15 18:44:42
|
I want to make a legend. Looking at the existing Legend class, I'm not sure I have precise control over positioning, which I would like to have (i.e., put it in a specific rectangle). I would also like to put legend items in a horizontal layout, or perhaps put them in columns. I'm not sure Legend can do this. However, it is easy enough to make a do-it-yourself legend by creating an Axes and plotting points and text on it. Will this be necessary? Mike |
From: John H. <jdh...@ac...> - 2003-09-30 16:34:18
|
>>>>> "Charles" == Charles Twardy <ct...@ma...> writes: Charles> I couldn't see any way to do legends, so I hacked Charles> together a routine that worked for me. However, I don't Charles> know how to handle fonts properly (ie, find out how much Charles> plotting space they really take up), so someone might Charles> want to fix the two lines marked "#Hack" and maybe the Charles> related row spacing. Thanks for the script. I've been meaning to add legends for some time and you gave me the push I needed. To do it right (account for font size) is a little more difficult so I've been putting it off, but it's done in CVS now and tested with the 3 backends. I added the legend functionality to the Axes class, which has the advantage that you don't need to specify the line styles, colors etc... since the axes contains the lines and can get them from there. Also, I decided not to go with a whole new legend axes, but rather added a legend patch, legend lines and legend text to the current axis. Changes to axes lines with handle graphics or Line2D API calls are reflected in the legend text. Below is your script which works with the CVS version. Do you mind if I add it to the examples dir in the matplotlib distro? JDH # Thanks to Charles Twardy from matplotlib.matlab import * a = arange(0,3,.02) b = arange(0,3,.02) c=exp(a) d=c.tolist() d.reverse() d = array(d) ax = subplot(111) plot(a,c,'k--',a,d,'k:',a,c+d,'k') legend(('Model length', 'Data length', 'Total message length'), 'upper right') ax.set_ylim([-1,20]) ax.grid(0) xlabel('Model complexity --->') ylabel('Message length --->') title('Minimum Message Length') set(gca(), 'yticklabels', []) set(gca(), 'xticklabels', []) savefig('mml') show() |
From: Charles R. T. <ct...@ma...> - 2003-10-02 04:43:57
|
On Tue, 30 Sep 2003, John Hunter wrote: }done in CVS now and tested with the 3 backends. Now _that's_ service! :-) :-) :-) Sounds like your implemention makes much more sense, as expected. }Below is your script which works with the CVS version. Do you mind if }I add it to the examples dir in the matplotlib distro? I'd be honored! Waiting for my cvs mirror to catch up.... -C -- Charles R. Twardy, Res.Fellow, Monash University, School of CSSE ctwardy at alumni indiana edu +61(3) 9905 5823 (w) 5146 (fax) "in much of the rest of the world, rich people live in gated communities and drink bottled water." --Jared Diamond |