Matplotlib PDF backend slow?

守給你的承諾、 提交于 2019-12-23 19:47:36

问题


I'm writing a thousand plots to a PDF using matplotlib. I've already optimized the plotting code, ie. reusing figures/axes/lines and just changing the y data.

The bulk of the remaining time is spent in save_figure.

R, in comparison, seems to output a plot to PDF about 2x faster. Plots will all zero data seem to be even faster in R, while they're the same speed in Python.

I've set pdf.compression = 0, which makes a small improvement.

Tried rasterizing the data, it made no difference to plotting speed (although it used a ton of RAM).

Is there anything else I can try to speed up the matplotlib with PDF backend, or are there any alternative backends I should consider? I'm trying to beat R.

Thanks!


回答1:


Have to tried pyreport from Gael Varoquaux? You call it on your script, it then collects all calls to pylab.show(), makes a png of each and then creates a PDF from it.

It uses Latex in the end, so you'll need this. But I expect this might be faster, as PDF creation is delegated to Latex.



来源:https://stackoverflow.com/questions/15103724/matplotlib-pdf-backend-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!