NCL Home > Documentation > Functions > Graphics routines

boxplot

Creates and draws a boxplot.

Prototype

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"

	function boxplot (
		wks      : graphic,  
		x    [*] : numeric,  
		y [*][*] : numeric,  
		box0pts  : logical,  
		plotres  : logical,  
		lineres  : logical   
	)

	return_val [1] :  graphic

Arguments

wks

A Workstation identifier. The identifier is one returned either from calling gsn_open_wks or calling create to create a Workstation object.

x

A one-dimensional array containing the X-axis values of where the box plot(s) will be drawn.

y

A two-dimensional array, where the rightmost dimension contains the box plot reference pt. data. y(n,0)=bottom_value, y(n,1)=bottom_value_of_box, y(n,2)=mid-value_of_box,y(n,3)=top_value_of_box,y(n,4)=top_value.

box0pts

Two options attached as attributes may be attached here.
boxWidth ---- Sets the width of the box.
boxColors ---- An array that contains the colors that the boxes will be drawn in.
(Ex. boxOpts@boxColors = (/"green","blue"/))

plotres

An optional xy-plot resource list. Will override defaults where applicable.

lineres

An optional resource list pertaining to the lines used to draw the boxes/lines.

Return value

A scalar id of the XY plot created is returned. The id of the data object is also returned as an attribute called data. This is useful if you want to use setvalues to change some data options after this function has been called.

Description

This function creates a blank linLog plot object, on which box plots are created by extensive use of gsn_add_polyline.

You need to call gsnDraw and gsnFrame after calling this function, as by default the plot is not drawn and the frame is not advanced. This function may be used with gsn_panel.

Examples

For a set of application examples, please refer to the Boxplot Applications Page.