On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs <mmokr...@fold.natur.cuni.cz
> wrote:
> Ah, this seems to be the issue that my figsize was growing all the time so
> it
> went over the maximum limits.
>
> I thought this is valid:
> DefaultSize = F.get_size_inches()
> print str(DefaultSize)
> blah
> F.set_size_inches(DefaultSize)
>
> See http://matplotlib.sourceforge.net/api/figure_api.html
>
> <quote>
> set_size_inches(*args, **kwargs)
>
> set_size_inches(w,h, forward=False)
>
> Set the figure size in inches
>
> Usage:
>
> fig.set_size_inches(w,h) # OR
> fig.set_size_inches((w,h) )
>
> optional kwarg forward=True will cause the canvas size to be
> automatically updated; eg you can resize the figure window from the shell
>
> ACCEPTS: a w,h tuple with w,h in inches
> </quote>
>
> Nope, it does not work. The print call gives me: [ 8. 6.]. So, this is
> not a tuple?
> Or python-2.7 issue how is it printed ... I fear? ;-)
> Anyway, doing
>
> F.set_size_inches(11.2, 15)
>
> works for me.
>
> Martin
>
>
I am a little bit confused by your code example. You get the figure size
and print it, and *then* you set it with the exact same values, and you are
surprised that it came out as [8. 6.]? Note that the figure size is stored
internally as a numpy array, so when you do "print str(DefaultSize)", you
will get the string representation of the numpy array. You can still pass
in a tuple, list, or two separate elements. Try this code:
import matplotlib.pyplot as plt
fig = plt.figure()
print fig.get_size_inches()
fig.set_size_inches(11.2, 15.0)
print fig.get_size_inches()
fig.set_size_inches((4.0, 7.2))
print fig.get_size_inches()
fig.set_size_inches([9.3, 11.1])
print fig.get_size_inches()
You should see:
[ 8. 6.]
[ 11.2 15. ]
[ 4. 7.2]
[ 9.2 11.1]
Everything works as expected. There is nothing special about python 2.7 in
this regard. Let us know if you are still having problems updating your
figures and include a stand-alone example showing how the figure size is
not being updated.
Cheers!
Ben Root
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users