matplotlib bitmap plot with vector text
bitmap, matplotlib, python, vector-graphics
Solution
It should be as simple as passing in `rasterized=True` to the `plot` command.
E.g.
import matplotlib.pyplot as plt
plt.plot(range(10), rasterized=True)
plt.savefig('test.pdf')
For me, this results in a pdf with a rasterized line (the resolution is controlled by the dpi you specified with `savefig` -- by default, it's 100) and vector text.
Problem
So, I'm plotting a waveform (and other things) that result in a bigger vector file (PDF) than the corresponding raster file (PNG). I imagine this is because the dataset plotted is very large and there are millions of instructions in the vector file. Other than being bigger, the PDF is also quite hard for the PDF reader to display. On some, it takes a few seconds to load; on others, it doesn't load at all. In pyplot, is it possible to have a bitmap plot with vector axes, labels and all other text? My (very bad) solution at the moment is to generate the PDF, generate the PNG, open the PDF with inkscape and replace the plot with the PNG one. Obviously this is too manual and very time consuming if you realise you have to regenerate the plot.