Re: odd wrapping behavior w/ logarithmic axis for xy plot

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon, 31 Jul 2006 23:08:15 -0600 (MDT)

> When I run the attached ncl script foo.ncl, I get the attached eps file. The
> script is plotting y=x & y=x^2, 0<x<=1, with a logarithmic x axis style. The
> x values in the y=x^2 curve appears to be wrapping around and producing an
> incorrect curve on the figure.
>
> Any idea what is going wrong and how to fix it and/or work around it?
>
> This is a simplified script. My application of interest is a power spectrum
> density figure that I am attempting to generate. In that figure, I am getting
> a similar wraparound effect.
____________________________________________________

The following illustrates what works and fails.
Basically, "5.0 * x(0)" specifies that the
user specified trXMinF is to the right (ie, > min(alog10(x))

[1]
    res_at_xyXStyle = "Log"
    res_at_trXMaxF = 1.0
   ;res_at_trXMinF = 5.0 * x(0) ; fails
    res_at_trXMinF = x(0) ; works
   ;res_at_trXMinF = 0.001 ; works
    res_at_trYMaxF = 1.0
    res_at_trYMinF = -1.0

[2] Commenting the following
   ;res_at_xyXStyle = "Log"
     means all the above res_at_trXMinF settings work.

[3] Keith wants

     res_at_trXMinF = 5.0 * x(0)

     so a work around is

     res_at_trXMinF = 5.0 * x(0)
     res_at_xyXStyle = "Log"

     i = ind(x.ge.res_at_trXMinF)
     p = gsn_xy(wks,x(i),y(:,i),res)

[4] Basically there appears to be a bug when
               xyXStyle = "Log"
     and the user specifies trXMinF to be greater than the actual
     min value of the series.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
begin
    N = 500
    x = (1.0 * ispan(1,N,1)) / N
    y = new( (/ 2, N /), float )

    y(0,:) = x
    y(1,:) = x ^ 2

    xx = log10(x)
    print( x(0:10)+" "+y(0,0:10)+" "+y(1,0:10)+" "+xx(0:10) )
   ;print( x+" "+xx+" "+y(0,:)+" "+y(1,:) )

    wks = gsn_open_wks("x11", "foo")

    res = True
    res_at_trXMaxF = 1.0
   ;res_at_trXMinF = 5.0 * x(0) ; fails
   ;res_at_trXMinF = x(0) ; works
    res_at_trXMinF = 0.001 ; works
    res_at_trYMaxF = 1.0
    res_at_trYMinF = -1.0
    res_at_xyXStyle = "Log"
    res_at_xyLineThicknessF = 2

    p = gsn_xy(wks,x,y,res)

end
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 31 2006 - 23:08:15 MDT

This archive was generated by hypermail 2.2.0 : Tue Aug 01 2006 - 16:53:55 MDT