[SciPy-user] Matplotlib/pylab help

James Coughlan coughlan@ski....
Fri Apr 27 15:59:35 CDT 2007


Hi,

Ryan, thanks for the ylim solution. Just wanted to point out that one 
more step needs to be taken to display matrices in image form (such as 
matrices that represent images), when the y axis typically designates 
row number, which increases from the top to the bottom of the figure. 
The ylim function does make the y-axis increase from top to bottom, 
*but* the entire image then appears upside down (i.e. flipped about the 
middle row).

To correct this, just use the flipud() function. Example:

h,w=im.shape #im is grayscale image
figure()
imshow(flipud(im))
ylim([h, 0])

If anyone knows an easier solution, please let me know. (In Matlab it's 
as simple as typing "axis ij" after displaying the matrix.)

Best,

James

Ryan Krauss wrote:
> I think it is as simple as specifying your ylim to be [ymax,ymin]:
>
> t=arange(0,0.2,0.001)
> y=sin(2*10*pi*t)
> plot(t,y)
> ylim([1.0,-1.0])
>
> On 4/27/07, Brandon Nuttall <bnuttall@uky.edu> wrote:
>   
>> Folks,
>>
>> I have a simple(?) question. I need to plot some data with the y axis
>> inverted. That is, the minimum y is at the top of the y axis (top left
>> corner of figure) and the maximum y in at the bottom of the y axis (bottom
>> left corner of figure) where it intersects the x axis. I'm plotting
>> depth-related data xy data. I've browsed the FAQs, docstrings, Matplotlib
>> User's Guide and haven't found out how to do this. I'm certain I'm
>> overlooking some argument or method somewhere.
>>
>> Thanks for any assistance.
>>
>> Brandon
>>
>>
>>
>> Brandon C. Nuttall
>>
>> BNUTTALL@UKY.EDU                         Kentucky Geological Survey
>> (859) 257-5500                                     University of Kentucky
>> (859) 257-1147 (fax)                              228 Mining & Mineral
>> Resources Bldg
>> http://www.uky.edu/KGS/home.htm       Lexington, Kentucky 40506-0107
>>
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user@scipy.org
>> http://projects.scipy.org/mailman/listinfo/scipy-user
>>
>>     
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>   


-- 
-------------------------------------------------------
James Coughlan, Ph.D., Associate Scientist                     

Smith-Kettlewell Eye Research Institute

Email: coughlan@ski.org
URL: http://www.ski.org/Rehab/Coughlan_lab/
Phone: 415-345-2146 
Fax: 415-345-8455
-------------------------------------------------------



More information about the SciPy-user mailing list