Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure the behavior of the Qt4Agg backend?

In an earlier question I learned that the behavior on show() was dependent on the backend in use by matplotlib. At that time I was looking for a way to keep show() from deleting the drawing elements of a figure, concluding that by switching from Qt4Agg to TkAgg, the drawing elements would be preserved even if the figures were closed. I would like to increase my superpowers by learning, if possible, how to configure the Qt4agg backend to behave as desired.

like image 344
2NinerRomeo Avatar asked May 18 '11 19:05

2NinerRomeo


People also ask

How do I check my Matplotlib backend?

To check that pylab/pyplot backend of Matplotlib runs inline, we can use get_backend() method. The method returns the name of the current backend.

How do you use Matplot?

As noted above, there are essentially two ways to use Matplotlib: Explicitly create Figures and Axes, and call methods on them (the "object-oriented (OO) style"). Rely on pyplot to automatically create and manage the Figures and Axes, and use pyplot functions for plotting.


1 Answers

Instead of trying to exercise extra control over the backend, just create the figures and keep references to them yourself, as shown in the highest-rated answer to your first question. The problem with trying to manipulate the backend, as you are asking to do here, is that the backend is not intended to hand your figures back to you intact once you have looked at them; that's not normally the backend's job. See: matplotlib figures disappearing between show() and savefig()

like image 166
Brandon Rhodes Avatar answered Oct 02 '22 19:10

Brandon Rhodes