3

I could only find this from their help section.

Configure matplotlib for interactive use with the default matplotlib

I have been having performance issues plotting using matplotlib.pyplot with the IPython command-line until I tried the --matplotlib option.

Example

Without --matplotlib

 $ ipython
 In [1]: import matplotlib as mpl

 In [2]: import matplotlib.pyplot as plt

 In [3]: mpl.get_backend()
 Out[3]: u'Qt4Agg'

 In [4]: plt.plot([0, 1, 2], [0, 1, 2])
 Out[4]: [<matplotlib.lines.Line2D at 0xb473198>]
 # IPython command-line becomes entirely unresponsive, must restart IPython to become usable again

With --matplotlib

 $ ipython --matplotlib
 In [1]: import matplotlib as mpl

 In [2]: import matplotlib.pyplot as plt

 In [3]: mpl.get_backend()
 Out[3]: u'Qt4Agg'

 In [4]: plt.plot([0, 1, 2], [0, 1, 2])
 Out[4]: [<matplotlib.lines.Line2D at 0xcbe1d68>]
 # IPython command-line remains responsive

I suspect a side-effect of using the --matplotlib argument is boosting my performance, but I'd like to know how.

Setup

  • IPython: 3.0.0
  • matplotlib: 1.4.3
  • Python: 2.7.9 :: Anaconda 2.2.0 (64-bit)
  • Windows 7 (64-bit)

1 Answer 1

1

I think it is the equivalent of setting plt.interactive(True) (i.e. turning interactive mode on, or equivalently running plt.ion()), so that when a figure instance is created, you still have control of the terminal. See here for more information.

For example:

$ ipython --matplotlib

import matplotlib.pyplot as plt
plt.isinteractive() 
# True

As opposed to:

$ ipython

import matplotlib.pyplot as plt
plt.isinteractive() 
# False

As a side note, in your first example, the command line will remain unresponsive until you close the figure that is created by your plt.plot command. Once you close that window, you should regain control of the command line.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Tom, although I think something additional is happening as I still see the performance issues after using plt.ion(). In my first example, the figure is never displayed as I don't call plt.show(). I'm sorry if I wasn't clear enough originally, but by 'unresponsive' I meant each keystroke takes about 1/4 second to appear, rather than simply blocking input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.