bug-ish behaviour on gsn_csm_xy

From: Álvaro M. Valdebenito B. <alvaro.valdebenito_at_nyahnyahspammersnyahnyah>
Date: Mon, 19 Jan 2009 14:25:18 +0100

Hi everyone,

while testing a ncl script for scatter plots,
I found a bug-ish behaviour on gsn_csm_xy.

When I changed the xyXStyle and xyYStyle
resources from "Linear" to "Log",
4 straight lines disappeared from the plot.

I thing that the reason for this
is that the extremes of the lines are a bit outside of the
window on "Log" style, and then the lines are not plotted.

I have found a solution to my problem,
but I think that this behaviour may be a bug.

To see the solution, look on the attached script for:
   datax(1,0:1) = (/dmin,dmax/) ; lines disappear on "Log" plots
; datax(1,:) = fspan(dmin,dmax,npts); incomplete lines on "Log" plots
; datax(1,:) = dmin*(dmax/dmin)^fspan(0,1,npts); SOLUTION

Sincerely,
Álvaro.

-- 
Álvaro M. Valdebenito B.                      alvaro.valdebenito_at_met.no
Air Pollution Section/Research Department     Tel. +47-2296 3397
Norwegian Meteorological Institute            http:\\www.met.no
P.O. Box 43 Blindern, 0313 Oslo, NORWAY       http:\\www.emep.int/CWF

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
; ===============================================
procedure scatter_plot(x[*]:numeric,y[*]:numeric,pres:logical)
local npts,dmin,dmax,datax,datay,res
begin
  npts = dimsizes(x)
  dmin = min((/min(x),min(y)/)) * 0.96
  dmax = max((/max(x),max(y)/)) * 1.10

  datax = new ( (/6,npts/), double)
  datay = new ( (/6,npts/), double)
  datax(0,:) = x
  datay(0,:) = y
  datax(1,0:1) = (/dmin,dmax/) ; lines disappear on "Log" plots
; datax(1,:) = fspan(dmin,dmax,npts); incomplete lines on "Log" plots
; datax(1,:) = dmin*(dmax/dmin)^fspan(0,1,npts); SOLUTION
  datay(1,:) = datax(1,:)
  datax(2,:) = datax(1,:)
  datay(2,:) = datax(1,:) * 1.857 ; 30% more
  datax(3,:) = datax(1,:)
  datay(3,:) = datax(1,:) * 0.538 ; 30% less
  datax(4,:) = datax(1,:)
  datay(4,:) = datax(1,:) * 3. ; 50% more
  datax(5,:) = datax(1,:)
  datay(5,:) = datax(1,:) * 0.333 ; 50% less

  wks = gsn_open_wks(pres_at_plot_type,pres_at_output)
  gsn_define_colormap(wks,(/"white","black","red","green","blue"/))

  res = True
  res_at_xyMarkLineModes = (/"Markers","Lines","Lines","Lines","Lines","Lines"/)
  res_at_xyMarkers = (/5/)
  res_at_xyDashPatterns = (/0,0,2,2,16,16/)
  res_at_xyMarkerColor = "black"

  res_at_trXMinF = dmin
  res_at_trXMaxF = dmax
  res_at_trYMinF = dmin
  res_at_trYMaxF = dmax
  if (isatt(pres,"XYStyle") ) then
    res_at_xyXStyle = pres_at_XYStyle
    res_at_xyYStyle = pres_at_XYStyle
  end if
  res_at_tmEqualizeXYSizes = True
  res_at_tiMainString = "Scatter plot"
  res_at_tiXAxisString = "Measurements"
  res_at_tiYAxisString = "Model results"

  plot = gsn_csm_xy (wks,datax,datay,res)
end

begin
  if(.not.isvar("range"))then
    range=(/0.01,1.00/)
  end if
  x=random_uniform(range(0),range(1),50)
  y=random_uniform(range(0),range(1),50)

  pres=True
  pres_at_plot_type="x11"

  pres_at_output="scatter_lin"
  pres_at_XYStyle="Linear"
  scatter_plot(x,y,pres)

  pres_at_output="scatter_log"
  pres_at_XYStyle="Log"
  scatter_plot(x,y,pres)
end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jan 19 2009 - 06:25:18 MST

This archive was generated by hypermail 2.2.0 : Wed Jan 21 2009 - 13:09:21 MST