Problems with bbox_inches='tight' #1135

Closed
pwuertz opened this Issue Aug 22, 2012 · 5 comments

Comments

Projects
None yet
2 participants
Contributor

pwuertz commented Aug 22, 2012

If I understood the method correctly, tight_bbox causes a figure to be printed to a in-memory buffer first, determines the bounding box of the figure contents and saves a new figure shrunk to the extent of the contents. Right?

Tight_bbox seems to have trouble figuring out the bounding box of a PDF created with latex using the pgf backend. This example produces a PNG and a PDF to be clipped with tight_bbox (make sure you are using the current master). The PNG is clipped correctly, the bounding box of the PDF is estimated incorrectly however.

import matplotlib as mpl
mpl.use('pgf')
import matplotlib.pyplot as plt

plt.figure()
plt.plot(range(5), markersize=2, marker='x')

plt.savefig('test.pdf', bbox_inches='tight')
plt.savefig('test.png', bbox_inches='tight')

I don't know exactly how tight_bbox works, or why it doesn't just calculate the figure's extent in the same way tight_layout solves that issue instead.

Owner

mdboom commented Aug 22, 2012

I'm marking this with the 1.2 milestone, because it would be nice to have this resolved for the release when many people are likely to try the new awesome PGF backend. We can let this slide if the solution turns out to be tricky.

Contributor

pwuertz commented Aug 22, 2012

Hm.. what is the kwarg bbox_inches_restore supposed to do? It is given to me at the second pass of print_pdf.. I'm getting some bounding box and a function..

pwuertz closed this Aug 22, 2012

Contributor

pwuertz commented Aug 22, 2012

I think I found the reason for this. Let's continue here:
#1138

pwuertz reopened this Aug 22, 2012

Contributor

pwuertz commented Aug 28, 2012

Workaround for matplotlib 1.2 release
#1155

Owner

mdboom commented Aug 28, 2012

I'm closing this because I understand #1155 resolves it (at least insofar as a temporary solution for 1.2.x). Please reopen if I'm mistaken.

mdboom closed this Aug 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment