|
From: Martin M. <mmo...@fo...> - 2013-05-20 16:42:45
|
Hi Ben,
Benjamin Root wrote:
>
>
>
> On Mon, May 20, 2013 at 12:02 PM, Martin Mokrejs <mmo...@fo... <mailto:mmo...@fo...>> wrote:
>
> Hi,
> I am having trouble to get space allocated for a long legend text,
> lets say spanning 2/3 - 3/4 of the whole output. I would like to have
> stacked barchart as 1st subplot and the place of remaining 3 subplots
> to be actually allocated by the legend. Alternatively, could I get the
> legend saved into a separate figure?
>
> Or could the space for legend text be allocated automatically minimizing
> output figure size? For example, the width would be 1120px while height
> be multiples of 840px (840 for each subplot)?
>
> Attached is a quick example. It shows also that I tried tight_layout()
> but wasn't successful with this either. I would be glad for some help,
> ideally converting the whole thing into an object-oriented approach.
> I am generating several figures in a row and would like to clear()/del()
> any previously used data ASAP.
>
>
> Thank you,
> Martin
> Am using mpl-1.2.2
>
>
> Try "fig.savefig('foobar.png', bbox_inches='tight')" when saving the
> image. It will make the figure size such that all the visible
> elements of the figure will fit into the saved output. tight_layout()
> is meant to make sure the elements don't overlap each other, but does
> nothing about making sure nothing gets clipped.
Ah, would be nice to make this clear in the docs. So far was doing
import pylab
F = pylab.gcf()
F.set_tight_layout(True)
which as you say does not help the way I thought.
Unfortunately, while
fig.savefig('foobar.png', bbox_inches='tight')
helped to get everything into the .png file (attached), the barchart itself
should span according to the code I posted just 1/2 of the figure. But somehow
it is enlarged and rescaled so that it occupies *more than* 1/2 of the figure.
What in pylab is resizing my image? Note: the final image is 625x1075.
Martin
|