Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Switching rendering backends #2851
Say I have a python script that I can call from IPython. I would like this script to
Is this currently possible within the same script?
I have tried with:
matplotlib.use('Agg') # The following figures will not render on the screen # but can be saved directly to disk matplotlib.pyplot.switch_backend('QT4Agg') # The following figures will render on the screen matplotlib.pyplot.switch_backend('Agg') # The following figures will not render on the screen # but can be saved directly to disk
with no luck. Is there anything that I am doing wrong?
Also, if I have a Python script that starts with:
import matplotlib matplotlib.use('Agg') from pylab import *
and then I call the script from my IPython session, and then I change the rendering backend in the script:
import matplotlib matplotlib.use('QT4Agg') from pylab import *
and then I run it again from the same IPython session, the changes do not seem to take effect. However, if I restart IPython the backend specification is taken into consideration.
This is all with the latest stable versions of Python, matplotlib and IPython.
Ok, switching backends seems to work nicely if I don't use the
I can keep switching backends this way and drawing plots without problems.
If, however, I use the magic
I could come up with other combinations and strange behaviours if it's useful. I get the feeling that this may already have been reported in another issue?? Or perhaps would be better in an issue of it's own.
Here's some versions of some perhaps relevant packages (all installed with pip):
IPython HEAD version
Now, in a virtualenv with everything the same (
(note: the backend_inline module has moved to
I know you're trying to clean out the cobwebs, but seeing as I can get unresponsive popups and crash the kernel by killing them if I do
I imagine it's a pain to fix. We should at the least do something like hijacking