SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] Patch for having legends outside right of plot

From: Kilian H. <hag...@eg...> - 2005年10月10日 13:49:41
On Friday 07 October 2005 16:30, John Hunter pondered:
> OK, I am happy to include this because I think the auto-resizing
> capability is useful (eg following the colorbar model). Now that you
> are aware of the figure legend, please take a look at your self.parent
> handling because parent can be an Axes or a Figure. You will want to
> check for isaxes before calling
>
> self.parent.get_position()
>
> and associated functions.
>
> Also, as a matter of style and efficiency, (snip)
Cool, I've rewritten my code with the suggested simplification and style 
concerns you put forward.
> Finally, I think your patch against your own tree, because it contains
> lines like
>
> - 'upper outside right' : 11,
> + 'upper outside right' : 11, # these only make sense with axes
> legends
>
>
> Eg, it is removing things that do not exist in matplotlib CVS -- make
> sure you apply diff against mpl CVS and not your own tree !
Oops, I diff'ed my most recent change against my first attempt instead of the 
original source, my bad. The original source tree I worked from was the 
mpl-0.84 tarball, but I guess using CVS is safer. Now, being a newbie to open 
source *developing* and CVS, how do I access and use mpl's CVS repository? Do 
you prefer my patches to be sent to this list or should I commit my changes 
to cvs?
More importantly though, after I made my changes I noticed that my axes 
resizing magic is based on the assumption that the plot the legend belongs to 
spans the width of the entire figure. This is not true in general and 
accordingly my new code, with resizing enabled, produces horrible results for 
e.g. subplot(121)/subplot(122), i.e. with multiple columns.
So, I thought just retrieve the dimensions of the current subplot somehow, but 
to no avail. Is there a way to retrieve the dimensions and/or position of the 
subplot, not the axes it contains? Something like lbwh=(0,0,0.5,1) for row 1, 
col 1 and lbwh=(0.5,0,0.5,1) for row 1, col 2 in the above example? That way 
I'd be able to calculate how much space axes + outside legend is supposed to 
occupy (my spaceNeeded variable).
Also, I see that this will only work when subplots are used, as soon as custom 
axes positioning/sizing is used such as that in examples/figlegend_demo.py, 
there seems to be no way to calculate this required space. Any way to check 
for this? Or should we leave it up to the user to turn resizing off if it 
doesn't give the desired results?
-- 
Kilian Hagemann
Climate Systems Analysis Group
University of Cape Town
Republic of South Africa
Tel(w): ++27 21 650 2748

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /