My apologies for two totally noob questions, but I can't quite seem to find these in the docs; a pointer would be great...
1. I would like to position a legend outside of the main plot area. The positioning part works great, but the legend is clipped to the pre-existing figure dimensions; how can I expand the figure size horizontally to allow for the legend? (And is there any way of auto-sizing the figure to include all of the stuff within it?)
2. In the horizontal bar chart I previously mentioned, the labels on the ticks on the Y-axis are clipped on the left side, as they are too long to fit into the pre-existing space. What's the best way of allowing more space for the tick labels, either by contracting the chart itself or expanding the figure?
Thanks in advance,
···
--
-- Christophe Pettus
xof@...3912...
My apologies for two totally noob questions, but I can’t quite seem to find these in the docs; a pointer would be great…
No problem. That is what we are here for.
- I would like to position a legend outside of the main plot area. The positioning part works great, but the legend is clipped to the pre-existing figure dimensions; how can I expand the figure size horizontally to allow for the legend? (And is there any way of auto-sizing the figure to include all of the stuff within it?)
This is actually something I deal with regularly. I haven’t found a good solution for the interactive viewing, but when saving a figure to an image file, you can do something like this (assume that the legend object is stored in a variable named “leg”):
fig.savefig('foobar.png", bbox_inches=‘tight’, pad_inches=0.25, bbox_extra_artists=[leg])
- In the horizontal bar chart I previously mentioned, the labels on the ticks on the Y-axis are clipped on the left side, as they are too long to fit into the pre-existing space. What’s the best way of allowing more space for the tick labels, either by contracting the chart itself or expanding the figure?
In mpl v1.1.0, we introduced a function called “tight_layout” which should help with such things. Admittedly, it would be nice if tight_layout did something similar to bbox_inches=‘tight’ and accept a list of additional artist objects to consider, but it does not do that right now.
Cheers!
Ben Root
···
On Thu, Jan 12, 2012 at 12:09 PM, Christophe Pettus <xof@…83…3912…> wrote:
fig.savefig('foobar.png", bbox_inches='tight', pad_inches=0.25, bbox_extra_artists=[leg])
[...]
In mpl v1.1.0, we introduced a function called "tight_layout" which should help with such things. Admittedly, it would be nice if tight_layout did something similar to bbox_inches='tight' and accept a list of additional artist objects to consider, but it does not do that right now.
Both of those worked wonderfully... thanks very much!
···
On Jan 12, 2012, at 10:18 AM, Benjamin Root wrote:
--
-- Christophe Pettus
xof@...3912...