Closed floesmrt closed 5 years ago
You can not use the GR backend to write a PNG without using matplotlib.pyplot
.
The MPLBACKEND
environment only redirects the display output to the GR backend - savefig()
is handled by MPL itself.
But, you might use the GKS_WSTYPE environment to create the desired output, e.g.
export MPLBACKEND=gr
export GKS_WSTYPE=png
python ...
will create a file gks.png
using GR's cairopng
driver.
The fastest way to produce figure output with GR is by using the SVG or PDF output (especially for multi-page PDFs), e.g.
export GKS_WSTYPE=svg
will create an SVG file gks.svg
.
BTW: If you plan to create a movie, you can use export GKS_WSTYPE=mov
with your existing MPL script.
We are closing this issue due to inactivity. Please reopen the issue and let us know if its cause still persists with the current version of GR.
Hi,
I am new to GR. I read on the GR homepage: "... GR can be used as a backend for Matplotlib and significantly improve the performance of existing Matplotlib or PyPlot applications...". Can I use the GR backend to write a png (without using pyplot)? How? Will this be faster than using the agg backend?
I experimented with the sine example form the homepage. If I use it with plt.show(), using the gr backend is about 1.5 times faster than using the tkagg backend. If I naivly replace plt.show() by plt.savefig("test.png") the gr backend is slower than the agg backend. If I have a closer look at what functions are called, I realize that no matter what backend I specify always the file backend_agg.py is used, if I want to save a png.
Thanks Martina