Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spyder / iPython inline plot figure size

When I have a figure plotted from a script, I am able to vary the figure size as desired:

plt.figure(1,figsize=(20,20),dpi=72)
plt.imshow(a)
plt.show()

but when I do this in the iPython console, I cant get the figure size to vary. Why is this happening?

like image 471
shaunakde Avatar asked Oct 13 '16 09:10

shaunakde


People also ask

How do you increase the size of a plot in Spyder?

In Preferences > IPython console > Graphics > Inline backend you can adjust the width, height and dpi of inline figures.

Why is %Matplotlib inline?

Why matplotlib inline is used. You can use the magic function %matplotlib inline to enable the inline plotting, where the plots/graphs will be displayed just below the cell where your plotting commands are written. It provides interactivity with the backend in the frontends like the jupyter notebook.

Where is plot pane Options menu in Spyder?

The options menu in the top right of the Plots pane offers several ways to customize how your plots are displayed.


1 Answers

(Spyder maintainer here) By default the figures created in the Spyder IPython console are PNG files of fixed size.

If you want to zoom in/out or pan to left/right in a Matplotlib figure, you need to change your graphics backend from Inline (the default) to Automatic. You can do this by going to the menu

Tools > Preferences > IPython console > Graphics > Graphics backend

After doing this and restarting the kernel of the IPython console, or creating a new console, all Matplotlib figures will be created in a new window with controls for zooming and panning.

Finally, if you want to switch between Inline and Automatic while working in the console, you need to run these commands

  • %matplotlib inline to select the Inline backend.
  • %matplotlib qt5 or %matplotlib qt (depending if you're using Qt4 or Qt5) to select Automatic.
like image 137
Carlos Cordoba Avatar answered Oct 20 '22 01:10

Carlos Cordoba