6

I'm using spyder and pycharm for python coding. When I plot something with matplotlib in spyder it shows the result inline in IPython. With Pycharm IPython plots in a new extra window. I'm working on Windows7 and with Anaconda Python2.7.

Is it possible to plot in Pycharm inside in the IPython shell?

2
  • 1
    Try running %matplotlib inline before you start plotting. Commented Jun 13, 2015 at 22:36
  • In Community Edition 2020, the answer is no. The answers about Jupyter support only apply to PyCharm Professional Edition, as Jupyter support was removed from CE2019. Also, %matplotlib inline in the console gives: IPython.core.error.UsageError: Invalid GUI request 'inline', valid ones are:dict_keys(['none', 'osx', 'tk', 'gtk', 'wx', 'qt', 'qt4', 'qt5', 'glut', 'pyglet', 'gtk3']). Commented Jul 4, 2020 at 14:27

2 Answers 2

5

Not inside the shell; however, you can use an iPython notebook within PyCharm (2016+) for that purpose. PyCharm supports iPython plots when defined within a .ipynb (iPython/Jupyter file format) script.

Here is an example: Open, or create (as shown) a .ipynb script:

enter image description here

An here is what you get if you code inside a freshly made .ipynb file within PyCharm 2016 or later. Notice the %matplotlib inline, which comes after matplotlib.pyplot import.

enter image description here

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

1 Comment

Is there any way to make plots interactive in this way without creating a separate window?
2

PyCharm 2019.1+

In this version of PyCharm several great features to integrate Jupyter Notebooks and PyCharm were added.

First, create a new Jupyter Notebook or open up an existing one.

Second, you can Insert a new cell or you can work on existing cells.

enter image description here

Third, you can Run or Debug a Cell:

enter image description here

Fourth, if you run the cell, the result will be reflected in the right side of the screen.

enter image description here

3 Comments

Is it possible to further analyse the figure (ie, zoom, save, etc.), in a similar way to VSCode?
^ This is the key feature missing, VSCode has an edge here
Add %matplotlib qt after %matplotlib inline and press run all. The plots will open in a new window which can be resized, moved, zoomed and the plot can be saved as a file

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.