Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


BOXPLOT

BOXPLOT

The BOXPLOT function creates a box and whiskers plot from a data series containing a sample minimum, lower quartile, median, upper quartile, and sample maximum.

Examples


Copy and paste the following lines at the IDL command line to create the plot shown above:

; Create an array of the prairie dog hill diameters in order: 
; minimum, lower quartile, median, upper quartile, and maximum values
pdtown_arr = [ $
   [33.1, 98.6, 47.8, 37.7, 49.6], $
   [58.8, 107.3, 78.8, 60.3, 69.6], $
   [66.3, 120.5, 99.5, 95.4, 89.1], $
   [86.6, 146.0, 111.8, 108.7, 104.5], $
   [117.9, 154.1, 127.4, 120.6, 128.8]]
 
boxes = BOXPLOT(pdtown_arr, XTITLE="Site", YTITLE="Diameter (cm)", $
   TITLE="Prairie Dog Hill Diameters by Site", $
   FILL_COLOR='white', BACKGROUND_COLOR='linen')
 
; Change some of the properties after creating the plot.
boxes.FILL_COLOR = 'burlywood'
boxes.THICK = 2
boxes.XTRANSPARENCY = 50
boxes.YTRANSPARENCY = 50

Additional Examples

See BOXPLOT Examples for additional examples using the BOXPLOT function.

Syntax


graphic = BOXPLOT([Locations,] Values [, Keywords=value] [, Properties=value])

Keywords

Keywords are applied only during the initial creation of the graphic.

AXIS_STYLE=value

/BUFFER, /CURRENT, /DEVICE, DIMENSIONS=[width, height], LAYOUT=array, LOCATION=[x, y], MARGIN=scalar or [left, bottom, right, top], /NO_TOOLBAR, /NODATA, /OVERPLOT, /WIDGETS

CI_VALUES=array, MEAN_VALUES=array, OUTLIER_VALUES=array, SUSPECTED_OUTLIER_VALUES=array

Properties

Properties can be set as keywords to the function during creation, or retrieved or changed using the "." notation after creation.

ANTIALIAS, ASPECT_RATIO, AXES, BACKGROUND_COLOR, BACKGROUND_TRANSPARENCY, BOX, CLIP, COLOR, CROSSHAIR, ENDCAPS, FILL_COLOR, FONT_COLOR, FONT_NAME, FONT_SIZE, FONT_STYLE, HIDE, HORIZONTAL, LINESTYLE, LOWER_COLOR, MEDIAN, NAME, NOTCH, POSITION, SYMBOL_MEANS, SYMBOL_OUTLIERS, SYMBOL_SUSPECTED_OUTLIERS, THICK, TITLE, TRANSPARENCY, UVALUE, WHISKERS, WINDOW, WINDOW_TITLE, XRANGE, YRANGE

Methods


Close

ConvertCoord

CopyWindow

Delete

Erase

GenerateCode

GetData

GetValueAtLocation

MapForward

MapInverse

Order

Print

Refresh

Rotate

Save

Scale

Select

SetData

Translate

Return Value


The BOXPLOT function returns a reference to the created graphic. Use the returned reference to manipulate the graphic after creation by changing properties or calling methods.

Arguments


Locations

An M-element vector where M is the number of boxes representing the abscissa values to be plotted. If Locations is not specified, Values is plotted as a function of point numbers starting at zero. If both arguments are provided, Values is plotted as a function of Locations. If HORIZONTAL is set, these values will be located on the y-axis. If HORIZONTAL is not set (the default), these values will be located on the x-axis.

Values

An M x 5 element array defining the minimum, lower quartile, median, upper quartile, and maximum values to be represented in the box and whiskers. If HORIZONTAL is set, these values will be positioned along the x-axis. If HORIZONTAL is not set (the default), these values will be positioned along the y-axis. See CREATEBOXPLOTDATA for additional details on defining the input values.

Keywords


Keywords are applied only during the initial creation of the graphic.

AXIS_STYLE

Set this keyword to one of the following values:

  • 0 - No axes. Decrease the margins so the graphic almost fills the window. This is the default for images.
  • 1 - Single X, Y (and Z if 3D) axes located at the minimum data value. The margins will be adjusted to leave space for the axes. This is the default for 3D graphics.
  • 2 - Box axes - multiple axes located at both the minimum and maximum data values. The margins will be adjusted to leave space for the axes. This is the default for 2D graphics.
  • 3 - Crosshair-style axes - located at the midpoint of each data dimension. Since the axes are in the middle, decrease the margins so the graphic almost fills the window. This is the default for polar plots.
  • 4 - No axes, but use the same margins as if axes were there. This is useful if you want to later add another graphic that does have axes, and you want the two visualizations to be aligned properly.

You can set the following properties on the axes:

Property

Description

[XYZ]COLOR

A string or RGB vector containing the axis color.

[XYZ]GRIDSTYLE

A string, integer, or 2-element vector giving the linestyle for tickmarks.

[XYZ]LOG

Set to 1 if the axis is logarithmic. The minimum value of the axis range must be greater than zero.

[XYZ]MAJOR

The number of major tick marks. Set to -1 to auto-compute, set to 0 to suppress.

[XYZ]MINOR

The number of minor tick marks. Set to -1 to auto-compute, set to 0 to suppress.

[XYZ]SUBGRIDSTYLE

A string, integer, or 2-element vector giving the linestyle for the minor tickmarks. The default is 0, for solid lines. Set to -1 to force minor ticks to have the same linestyle as major ticks.

[XYZ]SHOWTEXT

Set to 1 to show text labels or 0 to hide the text labels.

[XYZ]STYLE

The axis range style. The valid values are:

(0) Nice range. Default for all graphics except Image, Barplot, and Map.

(1) Force the exact data range. Default for Image, Barplot, and Map.

(2) Pad the axes slightly beyond the nice range.

(3) Pad the axes slightly beyond the exact data range.

The [XYZ]RANGE takes precedence over this property.

[XYZ]SUBTICKLEN

The ratio of the minor tick length to the major tick length. The default is 0.5.

[XYZ]TEXT_COLOR

A string or RGB vector containing the axis text color.

[XYZ]TEXT_ORIENTATION

The angle (in degrees) of the tick mark labels.

[XYZ]TEXTPOS

Set to 1 to position text above the axis. The default is 0, below the axis.

[XYZ]THICK

Set to a floating-point value between 0 and 10 to specify the line thickness for tickmarks. A thickness of 0 gives a thin hairline. The default is 1.

[XYZ]TICKDIR

Set to 1 to draw the tickmarks facing outwards. The default is 0, facing inwards.

[XYZ]TICKFONT_NAME

A string containing the font name for the axis text.

[XYZ]TICKFONT_SIZE

The axis text size in points.

[XYZ]TICKFONT_STYLE

A string or integer containing the font style: normal (0), bold (1), italic (2), or bold italic (3).

[XYZ]TICKFORMAT

A string or string array of tick label formats. See Format Codes for more information.

[XYZ]TICKINTERVAL

The interval between major tick marks.

[XYZ]TICKLAYOUT

Set to 1 to suppress tick marks; set to 2 to draw a box around the tick labels.

[XYZ]TICKLEN

The length of each major tick mark, normalized to the width or height of the graphic. The default value is automatically calculated based upon the aspect ratio of the graphic.

[XYZ]TICKNAME

A string array containing the tick labels.

[XYZ]TICKUNITS

A string giving the tick units. Valid values are: null (the default, signified by empty quotes), Years, Months, Days, Hours, Minutes, Seconds, Time, exponent for exponential notation, or scientific for scientific notation.

If any of the time units are utilized, then the tick values are interpreted as Julian date/time values. If more than one unit is provided, the axis will be drawn with multiple levels.

[XYZ]TICKVALUES

An array of tick mark locations.

[XYZ]TITLE

A string giving the axis title.

[XYZ]TRANSPARENCY

An integer from 0-100 giving the percent transparency.

For more detailed explanations of these properties, see the AXIS function.

Tip: You can also use the AXIS function to insert additional axes after the graphic has been created.

BUFFER

Set this keyword to 1 to direct the graphics to an off-screen buffer instead of creating a window.

CURRENT

Set this keyword to create the graphic in the current window with a new set of axes. If no window exists, a new window is created. The WINDOW's SetCurrent method may be used to set the current window.

Or, set this keyword to an existing IDL Graphic reference to make that window be the current window and direct the new graphic to that window.

Tip: The CURRENT keyword is usually used with the LAYOUT keyword or POSITION property to produce a window which has multiple graphics in different locations.

Tip: If you want your graphic to share the same axes as an existing graphic, you should use the OVERPLOT keyword instead.

DEVICE

Set this keyword if values are specified in device coordinates (pixels) for the MARGIN and POSITION keywords. (Normalized coordinates are the default for these keywords.)

DIMENSIONS

Set this keyword to a two-element vector of the form [width, height] to specify the window dimensions in pixels. If you do not specify a value for DIMENSIONS, IDL by default uses the values of the IDL_GR_WIN_HEIGHT and IDL_GR_WIN_WIDTH preferences for Windows platforms or the IDL_GR_X_HEIGHT and IDL_GR_X_WIDTH preferences for X Windows systems on UNIX.

Tip: The minimum width is set by the toolbar in the window, usually around 400 pixels. If you want to create a smaller graphics window, you can use the NO_TOOLBAR keyword.

LAYOUT

Set this keyword to a three-element vector [ncol, nrow, index] that arranges graphics in a grid. The first dimension ncol is the number of columns in the grid, nrow is the number of rows, and index is the grid position at which to place the graphic (starting at element 1). This keyword is ignored if either OVERPLOT or POSITION is specified.

LOCATION

Set this keyword to a two-element vector [X offset, Y offset] giving the window's screen offset in pixels.

MARGIN

Set this keyword to the current graphic’s margin values in the layout specified by the LAYOUT property. Use a scalar value to set the same margin on all sides, or use a four-element vector [left, bottom, right, top] to specify different margins on each side.

By default, margin values are expressed in normalized units ranging from 0.0 to 0.5. If the DEVICE keyword is set, the values are given in device units (pixels).

This keyword is ignored if either OVERPLOT or POSITION is specified.

NO_TOOLBAR

By default the graphics window will have a toolbar containing some common tools such as Print and Save. Set this keyword to remove the toolbar. This keyword has no effect if the window is already created.

Tip: When the toolbar exists, the minimum window width is set to the toolbar's width, usually around 400 pixels. If you want to create a smaller graphics window, you can use the NO_TOOLBAR keyword.

NODATA

Set this keyword to 1 to create the graphic, but without any data attached to it. The axes and title (if present) are also created and displayed. If the OVERPLOT keyword is specified, axis ranges will not change.

Note: You must still provide valid input arguments. The data range of the input arguments are used to automatically set the range of the axes. The [XYZ]RANGE properties may be used to override these default ranges.

OVERPLOT

Set this keyword to 1 (one) to place the graphic on top of the currently-selected graphic within the current window. The two graphics items will then share the same set of axes. If no current window exists, then this keyword is ignored and a new window is created.

If you have a graphic in another window that is not currently selected, you can also set this keyword to that graphic's reference to overplot on top of that graphic.

Tip: If you want your graphic to have a new set of axes, you should use the CURRENT keyword instead.

WIDGETS

By default, when running from the IDL Workbench, the graphics window will use the native widgets for your platform. Set this keyword to instead use IDL widgets for the graphics window. This keyword is ignored when running from the IDL command line, since IDL widgets are always used in that case.

CI_VALUES

Set this to an M-element array denoting the confidence interval value around the median for each box. CI_VALUES are used to define the boundaries of the notch around the median if a notch is displayed. If set to an invalid value, i.e., the number of values does not match the number of boxes, no notches will be displayed.

Note: The NOTCH keyword must also be set in order to display notches on the boxes.

MEAN_VALUES

Set this to an M-element array containing the mean values to plot as symbols in each box. If set to an invalid value, i.e., the number of values does not match the number of boxes, no means will be displayed.

Note: IDL will ignore values outside of the allowed input.

OUTLIER_VALUES

Set this to a 2 x N-element array denoting up to N outlier values. For each value (x, y), x represents the box location and y represents the value at that location. If set to an invalid value (e.g., '0') no outliers will be displayed.

Note: IDL will ignore values outside of the allowed input.

SUSPECTED_OUTLIER_VALUES

Set this to a 2 x N-element array denoting up to N suspected outlier values. For each value (x, y), x represents the box location and y represents the value at that location. If set to an invalid value (e.g., '0') no outliers will be displayed.

Note: IDL will ignore values outside of the allowed input.

Properties


ANTIALIAS

By default, anti-aliasing is used when drawing lines. Set this property to 0 to disable anti-aliasing.

ASPECT_RATIO

Set this property to a floating-point value indicating the ratio of the Y dimension to the X dimension in data units. If this property is set to a nonzero value, the aspect ratio will be preserved as the graphic is stretched or shrunk. The default value is 0 for all graphics except images, meaning that the aspect ratio is not fixed but is allowed to change as the graphic is stretched or shrunk.

AXES (Get Only)

This property retrieves an array that contains all of the AXIS objects within the visualization. For example, for a plot visualization:

p = PLOT(/TEST)
 ax = p.AXES
ax[0].TITLE = 'X axis'
ax[1].TITLE = 'Y axis'
ax[2].HIDE = 1  ; hide top X axis
ax[3].HIDE = 1  ; hide right Y axis

See AXIS for a list of the available properties.

BACKGROUND_COLOR

Set this property to a string or RGB vector indicating the graphic's background color. The default value is [255, 255, 255] (white). Set this property to a scalar value to remove the background color.

Tip: To set the background color of the entire window, retrieve the window object using the WINDOW property, and set the BACKGROUND_COLOR on the window object.

BACKGROUND_TRANSPARENCY

Set this property to an integer between 0 and 100 to represent the percent transparency of the background color. The default is 100 (completely transparent).

Note: If you change the BACKGROUND_COLOR property and the current background transparency is 100, then the BACKGROUND_TRANSPARENCY will be automatically set to 0 (opaque) so that you can see the new color.

BOX

Set this property to 1 (the default) to draw the primary box, or to 0 to disable drawing the boxes.

CLIP

Set this property to 1 to clip portions of the graphic that lie outside of the dataspace range, or to 0 to disable clipping. The default is 1.

COLOR

Set this property equal to the color for the box and whisker lines. The default value is "black."

CROSSHAIR (Get Only)

Use this property to retrieve a reference to the Crosshair graphic. All graphics objects within the same set of axes share a single Crosshair graphic. For Plot graphics the default behavior is to display the crosshair when a Mouse_Down event is received. For other graphics the crosshair is disabled. The STYLE property may be used to automatically draw the crosshair, while the LOCATION property may be used to manually draw the crosshair.

You can get and set the following properties on the retrieved crosshair:

Property

Description

ANTIALIAS

Set to 1 to enable anti-aliasing for the lines.

COLOR

A string or RGB vector containing the color.

HIDE

Set to 1 to hide the crosshair, 0 to show.

INTERPOLATE

Set to 1 to force interpolation between Plot data points when SNAP is active. For other graphics this property is ignored. The default is 0.

LINESTYLE

An integer or string giving the line style. The default is 'dot'. See Linestyle Values for additional options.

LOCATION

The location at which to draw the crosshair. For Plot graphics, if SNAP is enabled, then only the X coordinate needs to be supplied. Otherwise, LOCATION should be set to a two-element vector [X, Y] for two-dimensional graphics or [X, Y, Z] for three-dimensional graphics. If STYLE is currently "None", then setting the LOCATION will automatically set the STYLE to "Manual".

NAME

The name of the graphic.

SNAP

Set to 1 to snap the crosshair to the nearest Plot data point. For other graphics this property is ignored. The default is 1.

STYLE

An integer or string giving the crosshair style. Possible values are:
0 - "None" - never draw the crosshair. This is the default for all graphics except 2D plots.
1 - "Manual" - draw the crosshair using the LOCATION property.
2 - "Auto" - automatically draw the crosshair. This is the default for 2D plots.

THICK

The thickness of the lines. The default is 1.

TRANSPARENCY

The percent transparency of the lines. The default is 50.

UVALUE

An IDL variable of any data type.

For example, use the CROSSHAIR property to draw a crosshair on an image:

im = IMAGE(/TEST, TRANSPARENCY=50, AXIS_STYLE=2)
c = im.CROSSHAIR
c.COLOR = 'red'
c.THICK = 2
c.LOCATION = [300, 200]

See Creating Functions to Control Mouse Events for a more detailed crosshair example.

ENDCAPS

Set this property to 1 to draw the endcap lines on the whiskers. Set to 0 to turn off the endcap lines. The default is to draw the endcap lines.

FILL_COLOR

Set this property equal to the color used to fill the box. If not set or set to 0, the box is not filled.

Note: If LOWER_COLOR is set, it will override the value of FILL_COLOR for the lower portion of the box.

FONT_COLOR

Set this property equal to the text color for the title and axes (if present). The default value is "black".

FONT_NAME

Set this property equal to a string specifying the IDL or system font for the title and axes, if present. The default value is "DejaVuSans".

FONT_SIZE

Set this property equal to an integer specifying the font size for the title and axes, if present. The default value is 9 points for the axis text and 11 points for the title.

FONT_STYLE

Set this property equal to an integer or a string specifying the font style for the title and axes, if present. Allowed values are:

Integer

String

Resulting Style

0

"Normal" or "rm"

Default (roman)

1

"Bold" or "bf"

Bold

2

"Italic" or "it"

Italic

3

"Bold italic" or "bi"

Bold italic

HIDE

Set this property to 1 to hide the graphic. Set HIDE to 0 to show the graphic.

HORIZONTAL

If set, the boxes will be drawn horizontally (parallel to the x-axis). The default behavior is to draw vertical boxes (parallel to the y-axis). This is on a per boxplot basis; setting this property on a given boxplot will not affect any currently existing boxplots.

LINESTYLE

Set this property to the line style used to draw the whiskers and endcap lines. The default value is a solid line.

LOWER_COLOR

Set this property equal to the color used to fill the portion of the box below the median line. Setting this property will override the value of FILL_COLOR for the lower portion of the box. Set LOWER_COLOR to 0 to turn off the color in the lower portion of the box, which allows the box to be filled completely with the FILL_COLOR.

LOWER_COLOR must be used in conjunction with FILL_COLOR. Set FILL_COLOR in order to enable the use of LOWER_COLOR.

MEDIAN

Set this keyword to draw a median line in each box. The default is to draw the median line.

NAME

Set this property to a string that specifies the name of the graphic. The name can be used to retrieve the graphic using the brackets array notation. If NAME is not set then a default name is chosen based on the graphic type.

NOTCH

Set this property to draw a notch at the median value using CI_VALUES. The default is not to draw a notch at the median value.

POSITION

Set this property to a four-element vector that determines the location of the visualization within the graphic window. The coordinates (x0, y0) represent the lower left and (x1, y1) represent the upper right corners of the data space. Coordinates are expressed in normalized units ranging from 0.0 to 1.0. If the DEVICE property is set, the units are given in device units (pixels).

Note: After creation, you can set the POSITION to either a two- or four-element vector. If two elements are provided, the center of the graphic will be translated to that position. If four elements are provided, the graphics will be translated and scaled to fit the position.

SYMBOL_MEANS

Use this graphic symbol to control all of the symbol properties for the mean values, if specified. See SYMBOL for more information.

SYMBOL_OUTLIERS

Use this graphic symbol to control all of the symbol properties for the outlier values, if specified. See SYMBOL for more information.

SYMBOL_SUSPECTED_OUTLIERS

Use this graphic symbol to control all of the symbol properties for the suspected outlier values, if specified. See SYMBOL for more information.

THICK

Set this property to a value between 0 and 10 to set the thickness of the line defining each box, the whiskers, and endcaps. A thickness of 0 displays a thin hairline on the chosen device. The default value is 1.

TITLE

Set this property to a string specifying a title. The title properties may be modified using FONT_COLOR, FONT_NAME, FONT_SIZE, and FONT_STYLE. After creation the TITLE property may be used to retrieve a reference to the title text object, and the TEXT properties may be used to modify the title object.

You can add Greek letters and mathematical symbols using a TeX-like syntax, enclosed within a pair of "$" characters. See Adding Mathematical Symbols and Greek Letters to the Text String for details.

TRANSPARENCY

Set this property to the percent transparency of the boxes and the lines. This value can be an integer between 0 and 100. The default value is 0.

UVALUE

This property holds a user-defined value. Set this property to an IDL variable of any data type.

WHISKERS

If set to 1, the default, whisker lines will be drawn. Set this property to 0 to turn off the whiskers.

WIDTH

Set this property to the width of lines denoting the box and whiskers (the span in the X direction for vertical boxes), in data units. The default is 0.4 ([location-0.2, location+0.2]). If set to an M-element array, each element will represent the width of the box at that index.

WINDOW

This property retrieves a reference to the WINDOW object which contains the graphic.

WINDOW_TITLE

Set this property to the title of the IDL Graphic window. The title is displayed in the window's title bar.

XRANGE

Set this property to a two-element vector giving the X data range to plot. The default behavior is to plot the entire data range.

YRANGE

Set this property to a two-element vector giving the Y data range to plot. The default behavior is to plot the entire data range.

Additional Examples


Copy and paste the following lines at the IDL command line to create the plot shown above:

 
; Create an array of the CDC weight data  in order: 
; minimum, lower quartile, median, upper quartile, and maximum values
weight_arr = [ $
   [100.4, 100.0, 100.0, 100.1], $
   [165.19, 166.19, 148.94, 134.94], $
   [241.75, 221.47, 193.06, 177.94], $
   [293.69, 272.14, 261.19, 250.81], $
   [987.88, 1208.31, 1033.06, 726.75]]
 
wt_boxes = BOXPLOT(weight_arr, XTITLE="Weight (lbs)", /HORIZONTAL, $
   TITLE="CDC Self-Reported Weights by Region, Males", $
   FILL_COLOR='white', BACKGROUND_COLOR="light gray")
 
 
; Hide the y-axis since it is unnecessary 
wt_boxes.YTRANSPARENCY = 100
 

Use the BOXPLOT window controls to annotate the boxes, apply bold to the title, and change its font size to 18:

Version History


8.2.2

Introduced

8.6 Changed default font name and font size.

See Also


!COLOR, PLOT, BARPLOT, CREATEBOXPLOTDATA, ERRORPLOT, Using IDL graphics, Formatting IDL Graphics Symbols and Lines



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us