Reputation: 5646
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
Upvotes: 3
Views: 231
Reputation: 69136
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.
Upvotes: 1