Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Andrea Crotti <andrea.crotti.0@gm...>  20110228 18:18:51

So since I wanted some space on the borders of my graph, I did this really extremely convoluted thing, which apparently works... I get a 10% more area on each side, but I'm quite sure there's a better way to this, right? I didn't find any function to pass an increment to the size that's why I did this mess... 8<cut herestart>8 old_axes = plt.axis() sizes = old_axes[1]  old_axes[0], old_axes[3]  old_axes[2] offset = lambda x: int((float(x) / 10)) new_axes = [] for i in range(len(old_axes)): new_val = old_axes[i] + (((1) ** (i + 1)) * offset(sizes[i % 2])) new_axes.append(new_val) plt.axis(new_axes) 8<cut hereend>8 
From: Gökhan Sever <gokhansever@gm...>  20110228 18:32:56
Attachments:
Message as HTML

On Mon, Feb 28, 2011 at 10:48 AM, Andrea Crotti <andrea.crotti.0@...>wrote: > So since I wanted some space on the borders of my graph, I did this > really extremely convoluted thing, which apparently works... > I get a 10% more area on each side, but I'm quite sure there's a better > way to this, right? > > I didn't find any function to pass an increment to the size that's why I > did this mess... > > 8<cut herestart>8 > old_axes = plt.axis() > sizes = old_axes[1]  old_axes[0], old_axes[3]  old_axes[2] > offset = lambda x: int((float(x) / 10)) > new_axes = [] > > for i in range(len(old_axes)): > new_val = old_axes[i] + (((1) ** (i + 1)) * offset(sizes[i % > 2])) > new_axes.append(new_val) > > plt.axis(new_axes) > 8<cut hereend>8 > > > >  > Free Software Download: Index, Search & Analyze Logs and other IT data in > RealTime with Splunk. Collect, index and harness all the fast moving IT > data > generated by your applications, servers and devices whether physical, > virtual > or in the cloud. Deliver compliance at lower cost and gain new business > insights. http://p.sf.net/sfu/splunkdev2dev > _______________________________________________ > Matplotlibusers mailing list > Matplotlibusers@... > https://lists.sourceforge.net/lists/listinfo/matplotlibusers > Hi, You can try: fig, ax = plt.subplots(1,1) ax.plot(range(10)) fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95) If you choose WXAgg as your backend you get a nice config tool to adjust spacing in the figure. Then just pass those numbers into .subplots_adjust method once you are satisfied.  Gökhan 
From: Paul Ivanov <pivanov314@gm...>  20110228 19:30:22
Attachments:
application/pgpsignature

Gökhan Sever, on 20110228 11:32, wrote: > On Mon, Feb 28, 2011 at 10:48 AM, Andrea Crotti > <andrea.crotti.0@...>wrote: > > > So since I wanted some space on the borders of my graph, I did this > > really extremely convoluted thing, which apparently works... > > I get a 10% more area on each side, but I'm quite sure there's a better > > way to this, right? > > > > I didn't find any function to pass an increment to the size that's why I > > did this mess... > > > > 8<cut herestart>8 > > old_axes = plt.axis() > > sizes = old_axes[1]  old_axes[0], old_axes[3]  old_axes[2] > > offset = lambda x: int((float(x) / 10)) > > new_axes = [] > > > > for i in range(len(old_axes)): > > new_val = old_axes[i] + (((1) ** (i + 1)) * offset(sizes[i % > > 2])) > > new_axes.append(new_val) > > > > plt.axis(new_axes) > > 8<cut hereend>8 > > You can try: > > fig, ax = plt.subplots(1,1) > ax.plot(range(10)) > fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95) Hi Andrea, I think Gökhan is pointing out a different feature than the one you want. You seem to want to adjust the x and y limits of the plot to be some fraction larger than the data that's plotted. You can do this with: ax = plt.subplot(111) ax.plot(range(10)) ax.set_ymargin(.2) ax.set_xmargin(.1) # or ax.margins(.1,.2) ax.autoscale() plt.draw() see also the docstring for ax.autoscale_view for more. best,  Paul Ivanov 314 address only used for lists, offlist direct email at: http://pirsquared.org  GPG/PGP key id: 0x0F3E28F7 
From: Andrea Crotti <andrea.crotti.0@gm...>  20110301 09:29:42

Gökhan Sever <gokhansever@...> writes: > Hi, > > You can try: > > fig, ax = plt.subplots(1,1) > ax.plot(range(10)) > fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95) > > If you choose WXAgg as your backend you get a nice config tool to adjust > spacing in the figure. Then just pass those numbers into .subplots_adjust > method once you are satisfied. Uhm strange, with the version of matplotlib that I have know I have subplots_adjust, but I don't have plt.subplots, was it added later? Well I can also leave my very convoluted way for now, I'll see later what to do... 
From: Andrea Crotti <andrea.crotti.0@gm...>  20110301 11:59:06

Paul Ivanov <pivanov314@...> writes: > > Hi Andrea, > > I think Gökhan is pointing out a different feature than the one > you want. You seem to want to adjust the x and y limits of the > plot to be some fraction larger than the data that's plotted. > > You can do this with: > > ax = plt.subplot(111) > ax.plot(range(10)) > ax.set_ymargin(.2) > ax.set_xmargin(.1) > # or ax.margins(.1,.2) > ax.autoscale() > plt.draw() > > see also the docstring for ax.autoscale_view for more. > > best, Uhm also autoscale and set_xmargin are not implemented in my version of matplotlib, too bad I'll just keep my hack for now... 
From: Paul Ivanov <pivanov314@gm...>  20110301 21:48:18
Attachments:
application/pgpsignature

Andrea Crotti, on 20110301 10:29, wrote: > Gökhan Sever <gokhansever@...> writes: > > You can try: > > > > fig, ax = plt.subplots(1,1) > > ax.plot(range(10)) > > fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95) > > > > Uhm strange, with the version of matplotlib that I have know I have > subplots_adjust, but I don't have plt.subplots, was it added later? > Well I can also leave my very convoluted way for now, I'll see later > what to do... plt.subplots was added somewhat recently  in this instance it's equivalent to : fig = plt.figure() ax = plt.subplot(1,1,1) Andrea Crotti, on 20110301 12:58, wrote: > Paul Ivanov <pivanov314@...> writes: > > You can do this with: > > > > ax = plt.subplot(111) > > ax.plot(range(10)) > > ax.set_ymargin(.2) > > ax.set_xmargin(.1) > > # or ax.margins(.1,.2) > > ax.autoscale() > > plt.draw() > > > > see also the docstring for ax.autoscale_view for more. > > Uhm also autoscale and set_xmargin are not implemented in my version of > matplotlib, too bad I'll just keep my hack for now... Ok, these were added within the past year as well. I think you should have an older version of ax.autoscale_view which does something similar  but it's effectively what you have done in your original example (though I'm not sure why you want cast everything as an int there, perhaps that's just what makes sense for the data you have). you can see the current code here, if you're curious: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes.py#L1774 best,  Paul Ivanov 314 address only used for lists, offlist direct email at: http://pirsquared.org  GPG/PGP key id: 0x0F3E28F7 
Sign up for the SourceForge newsletter:
No, thanks