Hej,
I\'d like to produce high quality PDFs from matplotlib plots. Using other code, I have produced a large array of numbers, which I plot in a figure using plt.ims
As suggested by steabert in the comments above, a workaround is exporting the graphics in a different format and then convert it to PDF afterwards. Adjusting my example from above, the workflow could look something like this:
import os
import matplotlib as mpl
mpl.use("Agg")
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['text.usetex'] = True
data = np.random.rand(50, 50)
plt.imshow(data, interpolation='nearest')
plt.xlabel('X Label')
plt.savefig('agg.eps')
os.system('epspdf agg.eps agg.pdf')
producing a file of 16 Kb which looks good. There is still one difference to the examples presented above: Using the (E)PS pipeline seems to ignore the interpolation='nearest' option, i.e. the image appears blurry in the final PDF. Luckily, I can live with that, but it might be interesting to look into this issue.