Re: Information on Box plot with NCL

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon, 11 Jun 2007 15:48:25 -0600

Hi Louis,

There is not an automatic way in NCL to do this (yet). Looking at the
r-documentation:
http://rweb.stat.umn.edu/R/library/graphics/html/boxplot.html

it looks like R automatically calculates (+plots) the median, min, max,
and 25th/75th percentiles of the data.

In NCL, you can use dim_median, dim_min, and dim_max to calculate the
median, min, and max. To calculate the 25th/75th percentiles, you can
sort the data by using qsort, and then use index subscripting to grab
the 25th and 75th percentile data.

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"
;*********************************************
begin
   nor = random_normal(292,15,(/2,125/)) ; set up data
   nor2 = random_normal(295,14,(/125/)) ; set up data

   dimt = dimsizes(nor) ; nor and nor2 have the same dimensions
   x25 = round(.25*dimt,3)-1 ; -1 to account for NCL indexing starting
   x75 = round(.75*dimt,3)-1 ; at 0

   qsort(nor) ; sort the data
   qsort(nor2)

   iarr=new((/2,5/),float)
   iarr(0,:)=(/min(nor),nor(x25),dim_median(nor),nor(x75),max(nor)/)
   iarr(1,:)=(/min(nor2),nor2(x25),dim_median(nor2),nor2(x75),max(nor2)/)

   wks = gsn_open_wks("ps","boxplot") ; create postscript file

   res = True ; plot mods desired
   res_at_tmXBLabels = (/"Control","Run A"/) ; labels for each box
   res_at_tiMainString = "Default Box Plot"
   res_at_trYMinF = 230.
   res_at_trYMaxF = 345.

   plot = boxplot(wks,(/0,1/),iarr,False,res,False)
   draw(wks) ; boxplot does not call these
   frame(wks) ; for you
end

Good luck,
Adam

louis Vonder wrote:
> NCL users,
>
> I want to know if there is a way to plot "Box plot" with NCL using time
> serie data which is organized like the one which attached.
>
> To be more explicit I want to know if it is possible like with "R
> software" just to read data and plot box for every column.
>
> In "R" the computation of the limit of the box is automatic, you have
> just to enter the column of data and the rest of the computation is the
> work of "R".
>
> In example http://www.ncl.ucar.edu/Applications/Scripts/box_1.ncl ,
>
> values of the limit of the box is entering manually, but not statically
> computed by NCL.
>
> Regards
>
> ------------------------------------------------------------------------
> Ne gardez plus qu'une seule adresse mail ! Copiez vos mails
> <http://www.trueswitch.com/yahoo-fr/> vers Yahoo! Mail
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 11 2007 - 15:48:25 MDT

This archive was generated by hypermail 2.2.0 : Thu Jun 14 2007 - 09:39:54 MDT