Legend frameon and tight bounding boxes


With matplotlib 1.1.1 on Gentoo I have been observing some strange
behaviour relating to ax.legend(frameon=False) and

from matplotlib.figure import Figure
from matplotlib.artist import setp
from matplotlib.backends.backend_cairo import FigureCanvasCairo
import numpy as np

fig = Figure()
ax1 = fig.add_axes([0.1, 0.5, 0.8, 0.4])
ax2 = fig.add_axes([0.1, 0.1, 0.8, 0.4], sharex=ax1)
x = np.arange(0, 10, 0.2)
for ax, y in zip((ax1, ax2), (np.cos(x), np.sin(x))):
    ax.plot(x, y, label='A line')

ax1.legend(loc='upper left', frameon=False)

setp(ax1.xaxis.get_ticklabels(), visible=False)
FigureCanvasCairo(fig).print_figure('test.png', bbox_inches='tight')

On my system the resulting image has a large left margin. However, if I
change frameon to True then the left margin is cropped (as expected).
Hence setting frameon=False for a legend appears to break tight bounding

A similar situation occurs if legend().draw_frame(False) is used to hide
the legend frame. My current work around is to use
legend().get_frame().set_visible(False) which results in the correct
bounding box.

I have also reproduced this using the AGG backend.

Regards, Freddie.

P.S. On an unrelated note are there any more performant alternatives to
bbox_inches='tight'? It almost doubles the rendering time of some more
complex plots.