18

After installing Anaconda3 & PyCharm in new PC, I tried to test the same code as uploaded here

And I got a window like this.

enter image description here

But usually I use the plot window like this format (from google image search) enter image description here

I think the first view is useful for checking all of the plots, but I'm already used to the second version, separated plot figure from PyCharm console, and I can use the control panel.

So I want to use PyCharm as in the second picture. How can I change my PyCharm settings to use the second version plot figure (extra window)?

Georgy
  • 12,464
  • 7
  • 65
  • 73
Gangil Seo
  • 256
  • 1
  • 3
  • 16
  • 1
    [Some blog post](https://blog.jetbrains.com/pycharm/2017/09/pycharm-2017-3-eap-1/) says "If you chose not to use scientific mode when we asked, you can always enable it later in View | Scientific Mode."; this suggest that the inverse should be possible as well, going to "View | Scientific Mode" and disabling it. Also, doing the inverse of what is suggested [here](https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000742510-Unable-to-use-mathplotlib-in-scientific-mode) might help. (I have not looked closer into this option or where to find it though) – ImportanceOfBeingErnest Jan 19 '18 at 08:31
  • I guess [this is the actual problem](https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000736584-SciView-in-PyCharm-2017-3-reduces-functionality-of-Matplotlib). – ImportanceOfBeingErnest Jan 19 '18 at 08:35

4 Answers4

47

That's because PyCharm is opening it in Sciview. Go to Settings => search for Python Scientific. Uncheck the (only) box Show plots in toolwindows. Restart PyCharm. It should work like a charm ;)

Related to my answer here.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Melvin
  • 1,530
  • 11
  • 18
  • Haven`t seen something about restart in other answers. Works immediately after unchecking the box. – A.Ametov Oct 09 '19 at 21:05
  • 2
    looks like only the professional version has this feature. The community version doesn't have it. – Moonlight Knight Oct 18 '20 at 04:27
  • didn't have to restart. – Gulzar Nov 03 '20 at 11:48
  • I did have to restart just the interpreter. Possibly reloading matplotlib would've done the trick too. – Michael Litvin Oct 27 '21 at 19:37
  • Using windows 10 and pycharm 2022.3, results in "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure". The Q55Agg answer next works for me in combination with this answer – tobi delbruck Dec 28 '22 at 18:09
  • I take that back. plotting in loop using Qt5Agg results in warning that calling plt.show() outside the main loop will likely fail and in fact showing the plot hangs my loop which is using matplotlib for rendering a simulation – tobi delbruck Dec 28 '22 at 18:14
11

According to this, you can manually change the backend to fix the issue:

matplotlib.use('Qt5Agg')

Credit to @ImportanceOfBeingErnest for digging up the thread.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
jpaugh
  • 6,634
  • 4
  • 38
  • 90
1

You need first to check if you have Pycharm Community or Pycharm Professional. You can plot in different windows just in case you have a professional version. You can use seeting -> scientific python ( link : https://www.jetbrains.com/help/pycharm/matplotlib-support.html ). Or, use matplotlib backends: Qt5Agg, Qt4Agg and TkAgg. (https://intellij-support.jetbrains.com/hc/en-us/community/posts/360004382380-Matplotlib-doesn-t-show-plots-in-new-window )

However, I can suggest you to download your plot in a file and close the window. So, you can have your plots in different windows. Check out this code:

file = '___your path___'
... make your code for visualisation 
plt.show()
plt.savefig(file+'\\fig.png')
plt.close('all')
datascientist
  • 81
  • 1
  • 6
0

I was having the same problem, and not resolving it by only switching off scientific mode. Just press Cmd + Shift + A or Ctrl + Shift + A and search python scientific, then click on it and deselect show plots in tool window, you should be all set now.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Lorenzo
  • 3
  • 3