1

I'm running Python 3.5.1 with matplotlib version 1.5.1 and iPython 5.0.0. I can't seem to get matplotlib's interactive feature working. I can run a command to create a plot:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1,2,3])

This doesn't show a figure until I manually execute plt.show(), at which point iPython hangs until I close the figure window. I have interactive set to True in my matplotlibrc file.

It's been a year or so since I used matplotlib. The last time I used it, I got interactive without having to execute plt.show(). Has something changed or am I doing something wrong?

jlconlin
  • 11,876
  • 20
  • 62
  • 91
  • For those not too familiar with matplotlib, what do you mean by interactive. you want the console to "not freeze" after the plot shows? Or you expect to "interact" with the plot window somehow? And how? – Tasos Papastylianou Aug 12 '16 at 17:08
  • 1
    @TasosPapastylianou It allows you to add data and manipulate the plot after it is created, by just continuing to use the object, and you should be able to see these changes dynamically on the figure window – Anonymous Aug 12 '16 at 17:09
  • there is an option you can pass to show() from what I remember, which stops it from freezing the console. I'll install the module and I'll let you know what it is, because I can't remember it by heart. – Tasos Papastylianou Aug 12 '16 at 17:12
  • 1
    the argument is **block**. i.e. `pyplot.show(block=False)` – Tasos Papastylianou Aug 12 '16 at 17:43

1 Answers1

2

You were probably using interactive mode previously.

Start ipython with:

ipython --pylab

Then your plots will show up instantly.

wim
  • 266,989
  • 79
  • 484
  • 630
  • I wish this were the answer, so simple. However, it didn't appear to have any effect for me. – jlconlin Aug 12 '16 at 17:13
  • 1
    Works for me. What backend do you use? Try calling `plt.ion()` once you're in ipython. – wim Aug 12 '16 at 17:14
  • `--pylab` is deprecated and clobbers namespaces! use `--matplotlib` – Paul H Aug 12 '16 at 17:55
  • @PaulH I wasn't aware the option was deprecated, and quick googling couldn't find details of that, do you have a link? – wim Aug 12 '16 at 18:09
  • turns out its not officially deprecated yet, but that's on the roadmap: http://stackoverflow.com/a/20528503/1552748 and https://mail.scipy.org/pipermail/ipython-dev/2014-March/013411.html. IPython and matplotlib devs alike really regret it. – Paul H Aug 12 '16 at 22:57