Hi all,
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:
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
As you can see, the figure title gets truncated.
We started using bbox_inches='tight' because otherwise in many cases
the images were coming back with insane amounts of white padding, and
Stefan vdW suggested this fix. But it seems that in other cases it
actually loses data, which is even worse...
A slightly more complicated example, using basemap, not only truncates
the title but also all the x and y labels:
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');
#####
produces:
http://img192.imageshack.us/img192/986/selection002e.png
This looks like a matplotlib bug, but I have no idea how easy it is to
fix. In the meantime, should we in ipython just revert back to not
using bbox_inches, or is there an alternative?
Thanks!
f