On Wed, 2 Mar 2011 22:01:02 +0900
Jae-Joon Lee <lee.j.joon@...> wrote:
> >> > Is this a bug?
> >> Unfortunately, bbox_inches option is never meant to be complete in
> >> figuring out the exact size of the figure area.
> > Why not? What's the purpose of bbox_inches='tight' otherwise?
> Figuring out enclosing bbox when arbitrary spline paths are involved
> is difficult (I think there is no exact solution). So I only intended
> to support common cases.
Ok, I can understand that, but shouldn't all artists used to construct the picture, as suptitle, be considered?
> >> However, you can use "bbox_extra_artists" keyword argument to specify
> >> additional artists that should be considered when dertermining the
> >> plot size.
> >> mytitle = fig.suptitle("Horray!", fontsize=20)
> >> ...
> >> fig.savefig("out.png", bbox_inches='tight', bbox_extra_artists=[mytitle])
> > That doesn't work for me either.
> Can you be more specific? Does it throw an exception? Or the code runs
> without any error but the output is still wrong?
No error/exception are produced. The output is simply identical to the one without bbox_extra_artists.
This also works in my previous example:
import matplotlib as mpl
fig = mpl.figure.Figure()
cvs = mpl.backends.backend_agg.FigureCanvasAgg(fig)
plot = fig.add_subplot(111)
st = fig.suptitle("Horray!", fontsize=20)
fig.savefig("out.png", bbox_inches='tight', bbox_extra_artists=[st])