Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot inline or a separate window using Matplotlib in Spyder IDE

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!

like image 772
pyan Avatar asked Mar 30 '15 21:03

pyan


People also ask

How do you plot a graph in Python Spyder?

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.


2 Answers

type

%matplotlib qt 

when you want graphs in a separate window and

%matplotlib inline 

when you want an inline plot

like image 97
Stefano Fedele Avatar answered Sep 20 '22 13:09

Stefano Fedele


Go to Tools >> Preferences >> IPython console >> Graphics >> Backend:Inline, change "Inline" to "Automatic", click "OK"

Reset the kernel at the console, and the plot will appear in a separate window

like image 40
AuHgNeM Avatar answered Sep 19 '22 13:09

AuHgNeM