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
Option to Compress Graphs for pgf-backend #5983
Comments
I didn't have time to read you example in detail but I think set_rasterized(True) may do what you want. Something like
Should ensure that the scatter is rendered as a bitmap. Hope that is helpful. |
That is exactly what I want. Thank you! |
Great. I think we need to document that better. I will rename this issue to reflect that if ok with you? |
Sure. I was looking for set_rasterized in the docs after you mentioned it, and it is somewhat hard to find I guess. |
I think the section about PGF should explain this. We actually have a test of this in the pgf backend https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/tests/test_backend_pgf.py#L160 but I don't think the docs here http://matplotlib.org/users/pgf.html mention it. |
Close now that the docs update has been merged |
Thanks for the work! |
Working with the awesome .pgf backend, I hit a limit as to how pretty I can make the graphs look:
The reason is obvious, when i produce a scatter plot with tens of thousands of objects, it will inevitably produce very large *.pgf documents. Now, I may have overlooked some features and am not an expert on this, but in some cases it may be beneficial if there was an option to save the graph itself as a png and let latex only do the annotations (afterall, its the beautiful typesetting we are after).
As an example my current workaround ("hack") is posted below. Obviously the quality of the graphs is reduced, and the pdf in my example has a bigger filesize, but i have produced *.pgfs of several mb which reduced to some kb in pdf (if they can be compiled at all). In my example the *.pgf size reduces by a third.
I would try to implement this myself in matplotlib, but am not sure where to start.
Is this a good feature, or are there better ways to achieve what I want?
Notes:
In this code I plot, save an image of just the plot without the axis as 'empty.png';
The problem is that this has the size of the figure and not the graph itself, so i have to crop the image.
This cropped image is then included using .imshow.
I looked in the source and knew that the pgf backend has a draw_image function, but got lost trying to figure out how it determines whether the plotted stuff is an image or not.
I may have confused my x's and y's.
The text was updated successfully, but these errors were encountered: