Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Problems with bbox_inches='tight' #1135

Closed
pwuertz opened this Issue · 5 comments

2 participants

@pwuertz
Collaborator

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.

@mdboom
Owner

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.

@pwuertz
Collaborator

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 pwuertz closed this
@pwuertz
Collaborator

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

@pwuertz pwuertz reopened this
@pwuertz
Collaborator

Workaround for matplotlib 1.2 release
#1155

@mdboom
Owner

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 mdboom closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.