1. Home
  2. RUGPLOT procedure

RUGPLOT procedure

Draws “rugplots” to display the distribution of one or more samples (P.W. Lane).


GRAPHICS = string token What type of graphics to use (highresolution, lineprinter); default high
TITLE = text Title for diagram; default *
AXISTITLE = text Title for axis; default *
WINDOW = scalar Window in which to draw high-resolution plot; default *, taken as 11 if SCREEN=clear, or 1 if SCREEN=keep
SCREEN = string token Whether to clear screen before high-resolution plot (clear, keep); default clea
ORIENTATION = string token Orientation of plots (down, across); default down
JITTER = number Ratio of jitter width to range of data in high-resolution plot; default 0.01
SEED = number Seed for generating random numbers used in jittering; default 0, i.e. continue from last generation, or initialize from system clock


DATA = variates Data to be summarized; no default
GROUPS = factor Factor to divide values of a single variate into groups; default *
RUGLABELS = texts Labels for individual rugs; default *, i.e. identifiers of variates or labels or levels of factor
POSITION = scalar or variate Position on x-axis (or on y-axis if ORIENTATION=across) at which to plot each rug; if GROUPS is set, positions for each level of the factor are taken from a variate; default is to draw a single rug on the axis, and to spread multiple rugs across the window


RUGPLOT draws pictures to display the distribution of one or more sets of data. In the simplest case, with the DATA parameter set to a single variate, RUGPLOT will draw a single vertical “rug”: that is, a series of short horizontal lines on the vertical axis, positioned at each value of the variate. The option ORIENTATION=across produces a horizontal rug. A rug can be added to an existing plot by specifying SCREEN=keep, and setting the WINDOW option to specify the window where the rug is to be drawn. With SCREEN=keep, the default window is 1; with SCREEN=clear, window 11 is used after defining it to fill the whole graphical frame.

If several variates are supplied, a rug is drawn for each of them using the same scale. Alternatively, if a single variate is specified by the DATA parameter, a factor with the same number of values as the variate may be defined by the GROUPS parameter, and a box will be drawn for each level of the factor. The rug plots are spread out across the window by default. The POSITION parameter can be set to specify where each rug is to be positioned on the x-axis (or y-axis if ORIENTATION=across). The setting should be in the range (0, n) for a plot with SCREEN=clear, where n is the number of rugs to be drawn; with SCREEN=keep, the position should be specified in the units of the axis last drawn in the window.

Line-printer rugplots can be drawn by setting option GRAPHICS=lineprinter. The plot is drawn with asterisks, or digits to represent points that are effectively coincident. If the page size is small, as in interactive mode, line-printer plots with ORIENTATION=down are very cramped: the PAGE option of the OUTPUT directive can be used to increase the depth of the graphs. The option ORIENTATION=down cannot be selected for line-printer plots with more than 14 rugs.

The TITLE and AXISTITLE options can be set to specify the titles displayed at the top of the plot and along the axis, for either graphics mode. The RUGLABELS parameter allows you to specify labels that will identify each rug, in place of the default labels taken from the variate identifiers, or factor labels or levels if the GROUPS parameter is set. Long identifiers or labels may overlap each other if ORIENTATION=down, or they may overlap the rug-plots if ORIENTATION=across; a maximum of eight characters is recommended.

In high-resolution plots, all data values are “jittered” to try to remove ties. This involves adding a small random value: by default the ratio of the maximum adjustment to the range of all the data is 1:100. This can be modified by setting the JITTER option to 0 to suppress jittering, or to some other ratio than the default of 0.01. The SEED option can be set to specify the seed of the random-number generation, if a reproducible plot is required.




High-resolution rugs are plotted using the minus or vertical-bar symbol, in vertical or horizontal plots respectively. Line-printer plots use the default plotting symbols, the asterisk or digits to represent coincident points.

Action with RESTRICT

Restrictions on the supplied variates are taken into account. The grouping factor and texts holding ruglabels, if specified, should not be restricted.

See also

Directive: DHISTOGRAM.


Commands for: Graphics.


CAPTION  'RUGPLOT example',\
         !t('1) The three variates America, Asia_Oc, Other contain the',\
         'heights of volcanoes in three regions of the world.',\
         'Simple rugplots are drawn to compare the',\
         'distribution of heights in each group.'); STYLE=meta,plain
VARIATE  America,Asia_Oc,Other; VALUES=!(199,197,193,185,177,172,157,156,140,\
RUGPLOT  [TITLE='Rugplots'; SEED=347687] America,Asia_Oc,Other
CAPTION  !t('2) A scatter plot is drawn of blood-pressure against age',\
         'for 38 women. Then two rugplots are added to show the',\
         'distribution of ages and pressures along the axes.')
VARIATE  [VALUES=82.17,88.19,89.66,81.45,85.16,89.77,89.11,107.96,\
         87.91,86.42,103.87,83.76,84.35,68.64,100.50,100.42] Pressure
VARIATE  [VALUES=28,46,63,36,42,59,54,77,21,57,47,34,51,27,24,41,66,\
         69,72,60,50,57,32,59,74,77,41,36,20,47,51,57,69,36,54,24,61,80] Age
DGRAPH   Pressure; Age
RUGPLOT  [SCREEN=keep; SEED=0] Pressure
Updated on March 5, 2019

Was this article helpful?