-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PGF backend does not clip image with specific bounding box #2586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you saying that parts of the figure are drawn outside the bounding box when you include the PGF code in LaTeX? Are you having any trouble with PDF produced by the PGF backend? Can you post some example code that illustrates the problem you are having? |
I just tried savefig() sending it to a pdf file and it has the same issue. The bounding box looks to be positioned correctly though. Incidentally, if I run this in ipython notebook, the pdf works although the notebook might be using a different backend for pdf, although I'm not sure. import numpy as np fig = plt.figure(1) plt.tight_layout() |
Sorry about closed/open I'm new to github |
Hm, I think the actual problem is that I never implemented support for user defined extents in |
Actually, the output isn't completely wrong. As you said, the size of the bounding box is right, the point of origin seems to be good, it appears to be some problem with the scaling. I had some problems with hardcoded dpi values in matplotlib earlier, maybe this is yet another of these cases. |
Yep, set |
Yup, that worked for the pdf, but not the pgf as you mentioned. If the first call of |
Ah ok, so in addition to the scaling error, "use as bounding box" doesn't seem to prevent pgf from drawing outside the boundaries. I'll include this in the fix for this issue. |
When setting the bbox_inches in savefig() to a specific size the resulting pgf file sets the bounding box to the appropriate dimensions but the image is not clipped. It seems that clip option should be added to the \pgfusepath command.
Current commands cut from top of pgf file:
\begingroup%
\makeatletter%
\begin{pgfpicture}%
\pgfpathrectangle{\pgfpointorigin}{\pgfqpoint{2.281265in}{2.224689in}}%
\pgfusepath{use as bounding box}%
Correct \pgfusepath command?:
\pgfusepath{use as bounding box,clip}%
I looked at the pgf file and see the use of \pgfusepath{clip} throughout deeper in the file however it doesn't clip the image. Adding clip as I did above gives the correct behavior in my latex document.
i created the pgf with a python command like:
extent = ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
fig.savefig('test.pgf', bbox_inches=extent)
The text was updated successfully, but these errors were encountered: