Re: how to make a scatter plot with a non-linear x-axis

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Sep 09 2010 - 06:16:47 MDT

Hi Adam,

I just realized last week or so that the gsn*Irregular2Linear type resources aren't recognized by the gsn_csm_y or gsn_csm_xy scripts.
I have a ticket open on this and hope to get to it soon.

Meanwhile, Larry, here's an example of how to do this:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin
  x = (/1,3,5,8,20,50,100/)
  y = (/1,8,2,3, 9, 4, 2/)

  xmin = min(x)
  xmax = max(x)
  ymin = min(y)
  ymax = max(y)

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

  res = True

;---Make sure NCL doesn't pick different min/max for axes
  res@trXMinF = xmin
  res@trXMaxF = xmax
  res@trYMinF = ymin
  res@trYMaxF = ymax

  res@tiMainString = "Regular X axis"
  plot = gsn_csm_xy(wks,x,y,res)

;---Change title of second plot
  setvalues plot
    "tiMainString" : "Irregular X axis"
  end setvalues

;---Create irregular plot object so we can force X axis to be irregular.
  irreg_axis = create "irregular" irregularPlotClass wks
    "trXMinF" : xmin
    "trYMinF" : ymin
    "trXMaxF" : xmax
    "trYMaxF" : ymax
    "trXCoordPoints" : x
  end create

;
; By overlaying linear plot on irregular X axis, (Y axis
; is still linear), we put it through transformation,
; forcing x axis to be irregular.
;
  overlay(irreg_axis,plot)

;---Draw new irregular xy plot.
  draw(irreg_axis)
  frame(wks)
end

--Mary

On Sep 2, 2010, at 9:53 AM, Adam Phillips wrote:

> Hi Larry,
> There are a few scatter plot examples here:
> http://www.ncl.ucar.edu/Applications/scatter.shtml
> You will probably want to use gsn_csm_xy (not gsn_csm_y), and also set
> the resource gsnXAxisIrregular2Linear = True, even though by the name of
> it you'd think you'd want to set that to False.
> Let us know if that doesn't help..
> Adam
>
> On 09/02/2010 06:53 AM, Larry McDaniel wrote:
>> Hello
>>
>> I would like to make a scatter plot with a non-linear x-axis, but not
>> logarithmic.
>>
>> such as (/.25,.5,.67,.57,.8,1.,1.25,1.5,1.75,2.,4./)
>>
>> any ideas, examples, advice?????
>>
>> Larry
>>
>
> --
> __________________________________________________
> Adam Phillips
> asphilli@ucar.edu
> National Center for Atmospheric Research tel: (303) 497-1726
> Climate and Global Dynamics Division fax: (303) 497-1333
> P.O. Box 3000
> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Sep 9 05:17:22 2010

This archive was generated by hypermail 2.1.8 : Thu Sep 16 2010 - 11:05:24 MDT