The currently implemented bounding box algorithm is very simple and it basically only accounts the title, axis label and ticklabels etc. I thought about implementing a general algorithm that accounts all the visible artist, but I found it very difficult (at least for me) given the support of the spline path and clipping. So, at the moment this is beyond me and I have no plan to improve it. But any contribution will be welcomed.
As a workaround, savefig can take bbox_extra_artists keyword (this may only be in the svn version though), which is a list artist that needs to be accounted for the bounding box calculation. So in your case, the below code will work. t1 = ax.text(-0.2,0.5,'text',transform=ax.transAxes) fig.savefig('test.png', bbox_inches='tight', bbox_extra_artists=[t1]) Given that this will not be fixed in near future and a workaround being suggested, I'm moving this to a feature request. -JJ On Thu, Jun 3, 2010 at 10:05 AM, Thomas Robitaille <thomas.robitai...@gmail.com> wrote: > Hello, > > I have run into a problem with the bbox_inches='tight' option which allows a > tight bounding box to be computed for a plot. In the following example: > > import matplotlib > matplotlib.use('Agg') > import matplotlib.pyplot as mpl > > fig = mpl.figure() > ax = fig.add_subplot(1,1,1) > ax.text(-0.2,0.5,'text',transform=ax.transAxes) > fig.savefig('test.png', bbox_inches='tight') > > matplotlib produces a plot where the text label does not appear. This may be > due to the bounding box algorithm not taking into account text written using > Axes.text that could fall outside the Axes. One solution is to use set_xlabel > and set_ylabel, for which the bounding box is correctly calculated, but in > some cases it is desirable to plot labels outside the box using 'text' (for > example if multiple labels are needed). > > I have submitted a bug report here: > > https://sourceforge.net/tracker/?func=detail&aid=3011032&group_id=80706&atid=560720 > > Cheers, > > Tom > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users