I have a Matplotlib scatter plot with 10,000+ points that I plan to insert as a figure in a LaTeX document for publication.
I would like the plot points to be raster graphics (e.g. PNG) because vector graphics with that many points often causes problems for PDF readers. I would like the ticks and axes labels to be vector graphics so I don't have to worry about resolution issues for the text and lines.
Is there a simple way to get matplotlib to make parts of the plot raster graphics while keeping the axes/ticks vector graphics?
My best guess so far is to do some sort of pre-render to PNG then imshow the resulting image with appropriate axes bounds before saving to PDF.
Add rasterized=True
to the call to plt.scatter
See the docs here
You can control the dpi of the rasterized parts of the figure by setting dpi=300
(for example) in the call to plt.figure
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With