matplotlib/matplotlib — Issue #688: bbox_inches='tight' clips figure.suptitle and lat/lon labels on basemap plots
Author: fperez
Created: 2012-01-29 20:19:19+00:00
State: open
Labels: confirmed

In ipython for the qtconsole and notebook, we send inline figures using

```
fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='tight')
```

as seen [here](https://github.com/ipython/ipython/blob/master/IPython/core/pylabtools.py#L104).

However, this produces truncated figure titles. Consider this code:

```python
f, ax = plt.subplots()
ax.plot(rand(100))
ax.set_title('Axis title')
f.suptitle('Figure title');
```

which produces this in the notebook:

![](http://img546.imageshack.us/img546/5448/selection001c.png)

A slightly more complicated example, using basemap, not only truncates
the title but also all the x and y labels:

```python
from mpl_toolkits.basemap import Basemap

lon0, lat0, lon1, lat1 = (84.38, 26.22, 88.9, 29.8)
resolution = 'i'

parallels = np.linspace(lat0, lat1, 5)
meridians = np.linspace(lon0, lon1, 5)

f, ax = plt.subplots()
m = Basemap(lon0, lat0, lon1, lat1, resolution=resolution, ax=ax)
m.drawcountries(color=(1,1,0)) # country boundaries in pure yellow
m.drawrivers(color=(0,1,1)) # rivers in cyan
m.bluemarble() # NASA bluemarble image
m.drawmeridians(meridians, labels=[0,0,0,1], fmt='%.2f')
m.drawparallels(parallels, labels=[1,0,0,0], fmt='%.2f')
f.suptitle('The Himalayas');
```

![](http://img718.imageshack.us/img718/7213/selection003k.png)

While we noticed this in the notebook, the problem will be present for any figure saving operation that supports `bbox_inches='tight'`.

As discussed in the [mailing list thread about this problem](http://sourceforge.net/mailarchive/forum.php?thread_name=CAHAreOqGuUEKXbbRWVxPgkd25WM4GkTdGbUB7x-aK%3DGD%3DAvYHg%40mail.gmail.com&forum_name=matplotlib-devel), mpl should probably use the position of 'official' artists such as basemap labels and figure suptitles in the computation of the bounding box.