In Spyder, plot using Matplotlib with interactive zoom, etc

[亡魂溺海] 提交于 2019-12-18 18:58:12

问题


I've recently switched from Enthought Canopy to Anaconda and am using the Spyder IDE. I've noticed that when I plot some data,

import matplotlib.pyplot as plt
plt.figure()
plt.plot(rigs2)
plt.ion()
plt.show()

It shows up as an inline figure in the IPython console:

However, in Enthought it used to be that the plot would show up in a separate window with zoom, back, and forward buttons. Is there any way to achieve the same in Spyder?


回答1:


Select from the menu Tools > Preferences, then IPython console in the list of categories on the left, then the tab Graphics at the top, and change the Graphics backend from Inline to e.g. Qt.
For me though, the figures then always pop up in the background.
(I use Spyder 3.0.0dev bundled with WinPython 3.4.)




回答2:


Even though it's an old question, my solution to the same issue without using the GUI.

Plot only in console:

%matplotlib inline 
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')

Going back to plot outside console:

%matplotlib qt5
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')

There was no need to restart my spyder or kernal. Session info:

spyder 3.3.2
python 3.6.8
windows 10. 



回答3:


And remember to restart the kernel and there it goes.




回答4:


You might not need to restart spyder. Just go to the tool menu and restart the kernel. Then you should have the plot displayed. Please, this is after you must have set the appropriate preferences for graphics



来源:https://stackoverflow.com/questions/36700083/in-spyder-plot-using-matplotlib-with-interactive-zoom-etc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!