Hi John

Your suggestions worked perfectly. Thanks!

As an aside, I had been composing my image as a GTK Pixbuf object (via
the gtk.gdk.pixbuf_new_from_data method: hacking about, poking values
into a big array of char) and I did notice that the
gtk.gdk.Pixbuf.get_pixels_array method didn't give me a correct plot. So
im=gtk.Image() then im=set_from_pixbuf(p) and im.show() doesn't give the
same thing as im=p.get_pixels.array() and imshow(im). Evidently the GTK
pixels array isn't laid out the same way as the Matplotlib pixels array.
Is that right? In any case, the answer was to write out to a png file,
then read back in using 'imread'.

wrt 'logspace', I think that a logspace implementation should be pretty
simple (the challenge would be more to know that it's doing all the
right things with namespaces and exceptions and ufuncs etc).

def logspace(low,high,num):
    return pylab.exp(pylab.linspace(pylab.log(low),pylab.log(high),num))

Perhaps someone else could clarify whether or not this implementation is
100% compatible with the Matlab one.

Cheers
JP


John Hunter wrote:
>>>>>> "John" == John Pye <[EMAIL PROTECTED]> writes:
>>>>>>             
>
>     John> Hi John, The image is correct when plotted using
>     John> i=imread('plot.png') then imshow(i), but I want to add
>     John> axes. I generated the image directly using GTK commands,
>     John> then saved the pixbuf as png. The pixels in the image
>     John> correspond to sample points in both x- and y-directions
>     John> generated using exp(linspace(log(low),log(high),num). Why is
>     John> there no logspace in matplotlib, btw?
>
> I'll be happy to add it -- how about sending a version?
>
>     John> All I basically need is a way to say what the range and
>     John> distribution of the pixels is: I don't want the axes to
>     John> default to integer-numbered linear-spaced values as they
>     John> currently do.
>
>     John> I tried to see if I could use the set_xscale command but it
>     John> seems to be internal and/or only applicable to polar plots?
>
>
> 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 = figure()
>   ax = fig.add_subplot(111)
>   im = nx.mlab.rand(500,500)
>   ax.imshow(im, extent=(1,501,1,501))
>   ax.set_xscale('log')
>   ax.set_yscale('log')
>   show()
>
> Hope this helps,
> JDH
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>   

-- 
John Pye
School of Mechanical and Manufacturing Engineering
The University of New South Wales
Sydney  NSW 2052  Australia
t +61 2 9385 5127
f +61 2 9663 1222
mailto:john.pye_AT_student_DOT_unsw.edu.au
http://pye.dyndns.org/



_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to