Hi Benjamin, thank you for you explanation. My comment is below in the text:
Benjamin Root wrote: > > > On Tue, Feb 14, 2012 at 4:43 PM, Martin Mokrejs <mmokr...@fold.natur.cuni.cz > <mailto: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: No, in my experience it did NOT work. I suspect F.set_size_inches() either did not like the input tuple or something else. Now. after reading your clarification, are you sure it can input the numpy array as well? What I also tried was to re-set the figsize to original values. Ouch, I use pylab not matplotlib directly. :( $ python Python 2.7.2 (default, Feb 7 2012, 19:33:08) [GCC 4.5.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pylab >>> F = pylab.gcf() >>> print F.get_size_inches() [ 8. 6.] >>> DefaultSize = F.get_size_inches() >>> print DefaultSize [ 8. 6.] >>> F.set_size_inches(10, 10) >>> print F.get_size_inches() [ 10. 10.] >>> F.set_size_inches(DefaultSize[0], DefaultSize[1]) >>> print F.get_size_inches() [ 10. 10.] >>> Why in the above example I cannot return back to figsize [ 8. 6.] ? > > 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] Yes, this works. > > 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. What does the internal numpy array representation bring good to the figsize? ;-) Why don't you use a simple list/tuple? I am sure you know what you're doing, am just curious. Especially if slicing behaves differently compared to list/tuple and the .__str__() also gives in my eyes weird output. Sure, matter of taste. ;) Thanks, Martin ------------------------------------------------------------------------------ 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