## Re: [Matplotlib-users] showing an image on log axes?

 Re: [Matplotlib-users] showing an image on log axes? From: David Huard - 2006-06-16 04:03:54 Attachments: Message as HTML Hi, Numpy has a logspace function, so it may be a bad idea to create a function in pylab with the same name that does something slightly different. def logspace(start,stop,num=3D50,endpoint=3DTrue,base=3D10.0): """Evenly spaced numbers on a logarithmic scale. Computes int(num) evenly spaced exponents from start to stop. If endpoint=3DTrue, then last exponent is stop. Returns base**exponents. """ y =3D linspace(start,stop,num=3Dnum,endpoint=3Dendpoint) return _nx.power(base,y) David 2006/6/15, Stefan van der Walt : > > On Tue, Jun 13, 2006 at 06:21:22AM -0500, John Hunter wrote: > > setting the xscale and yscale to 'log' should work fine, as long as > > you make sure the xaxis and yaxis do not contain nonpositive limits. > > For an MxN image, the default limits are 0..N-1 and 0..M-1 and the 0 > > will break the log transform. You can work around this by setting the > > image "extent" > > > > from pylab import figure, show, nx > > fig =3D figure() > > ax =3D fig.add_subplot(111) > > im =3D nx.mlab.rand(500,500) > > ax.imshow(im, extent=3D(1,501,1,501)) > > I often want to plot matrices, with the axes labeled according to the > matrix index. I.e. the top-lefthand element should be (0,0) and the > bottom-righthand element (rows,columns). Setting the extent does > work, i.e. > > ax.imshow(im,extent=3D(1,columns,rows,1)) > > If others also use this frequently, it may be useful to have a quick > way of doing it (or maybe, there already is, and I've missed it). > > Regards > St=E9fan > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >