Spyder controls figure size, ignoring specified figure dimensions

1,624 views
Skip to first unread message

Chris

unread,
Mar 10, 2012, 4:46:52 PM3/10/12
to spyd...@googlegroups.com
Hi,

Spyder seems to have a couple issues with taking control of figure properties without asking. Any ideas as to how to avoid these issues?

1) I've noticed that when plotting from Spyder via an ipython or python console, the figure size is limited to 12 inches wide by 6.725 inches tall (see below example script), when using the default dpi (different dpi changes the maximums). When running the script directly from python or ipython command line, the maximum height is not reached and goes to 8 inches tall as specified in the script.

from pylab import *

figs = []

w = 5

h = 5

for i in xrange(4):

    figs.append(figure(figsize=(w, h)))

    plot([1,2,3],[6,4,2])

    h = h+1

show()

for each in figs:

    print each.get_size_inches()


The output is:
[ 5.  5.]
[ 5.  6.]
[ 5.  6.725]
[ 5.  6.725]

2) A seemingly related issue-
Running the following in Spyder:

from pylab import *

fig=figure(figsize=(5,5))

plot([1,2,3],[6,4,2])

show()

fig.get_size_inches()


...gives a square figure window and the console output as expected:

[ 5. 5.]


However, running the following which specifies a different dpi:


from pylab import *

fig=figure(figsize=(5,5), dpi=50)

plot([1,2,3],[6,4,2])

show()

print fig.get_size_inches()


...gives a rectangular figure window and the console output:

[ 6.46 5. ]


So Spyder does not seem to be handling the dpi properly.


I tried it with Spyder 2.0.12 and the latest 2.1.8.


In the 2nd example with dpi, running directly from ipython or python command line gives square figures but with reported dimensions slightly larger than 5x5 inches. Adding these 2 lines to the start of the scripts:

import matplotlib as mpl

mpl.use('QT4Agg')

...makes it give 5x5 inches for both figures. (Adding those 2 lines to the start when running from Spyder has not effect since Spyder consoles have already chosen QT4Agg as the GUI backend.


Best,

Chris

Chris

unread,
Mar 11, 2012, 10:11:41 AM3/11/12
to spyd...@googlegroups.com
For the issue and examples below, I was using matplotlib 1.0.1.  After upgrading to matplotlib 1.1.0 the issue is fixed.

Best /Chris
Reply all
Reply to author
Forward
0 new messages