Plot inline or a separate window using Matplotlib in Spyder IDE

pyan picture pyan · Mar 30, 2015 · Viewed 158.4k times · Source

When I use Matplotlib to plot some graphs, it is usually fine for the default inline drawing. However, when I draw some 3D graphs, I'd like to have them in a separate window so that interactions like rotation can be enabled. Can I configure in Python code which figure to display inline and which one to display in a new window?

I know that in Spyder, click Tools, Preferences, Ipython Console, Graphics and under Graphics Backend select “automatic” instead of “inline”. However, this make all the figures to be in new windows. It can be messy when I have a lot of plots. So I want only those 3D plot to be in new windows, but all the other 2D plots remain inline. Is it possible at all?

Thanks!

Answer

Stefano Fedele picture Stefano Fedele · Apr 18, 2016

type

%matplotlib qt

when you want graphs in a separate window and

%matplotlib inline

when you want an inline plot