# Re: Information on Box plot with NCL

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.

;*********************************************
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,

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

```--
--------------------------------------------------------------