2

I just installed a python 3.6 kernel for my Jupyter notebook. In the past, with python 2.7, I was able to look at interactive plots in a separate window (i.e., not embedded below a cell in the notebook) by simply using the following.

import matplotlib.pyplot as plt
plt.plot([1,2,3],[4,5,6])
plt.show()

But now if I use this same code in the python 3.6 kernel, it appears just as if I had used

%matplotlib inline

in python 2.7: it's embedded in the notebook below the plt.show() command.

Can someone tell me how to use interactive plots in a python 3 Jupyter kernel?

UPDATE:

I discovered that

%matplotlib notebook

will give me an inline and interactive plot. Which is adequate for my purposes, but for the future, I would still like to know if it is possible to make new plotting windows as I originally asked.

UPDATE 2:

This thread offers the solution to use

%matplotlib qt

to restore the separate-window-plotting feature. But it is appears to pre-date python 3, and when I try the command, it returns

ModuleNotFoundError: No module named 'PyQt4'

FINAL UPDATE:

Apparently this will give me the functionality I wanted:

%matplotlib tk
crazunggoy47
  • 42
  • 1
  • 6
  • I'm not sure if this has anything to do with the version of python. Probably something else got updated as well. – ImportanceOfBeingErnest Nov 08 '17 at 16:58
  • Thanks for finding that other thread. But my question was not answered by it. See my UPDATE 2. – crazunggoy47 Nov 08 '17 at 17:04
  • @ImportanceOfBeingErnest, ok I've actually found that the solution was on the page you linked. At the very bottom. Thanks! – crazunggoy47 Nov 08 '17 at 17:08
  • `%matplotlib qt` is one of the options you have. If you don't have PyQt available, you can use the other menionned options `# wx, gtk, osx, tk, empty uses default` (this is mentionned in the very first answer there). Note that "empty" means `%matplotlib` without anything behind. – ImportanceOfBeingErnest Nov 08 '17 at 17:09
  • What isn't mentionned there is that you could try `%matplotlib qt5`, because python 3.6 would probably have pyqt5 if any. – ImportanceOfBeingErnest Nov 08 '17 at 17:13
  • Yes, using just %matplotlib gives me exactly the functionality I originally wanted. And yes, %matplotlib qt5 does work, and it also lets me change the axes from the GUI which is pretty neat. Thanks for your help. – crazunggoy47 Nov 08 '17 at 17:17

0 Answers0