Produces one-dimensional density (or violin) plots (D. B. Baird).
Options
BANDWIDTH = scalar |
Bandwidth for kernel smoothing (0-1); default density is chosen according to the number of observations |
---|---|
GAP = scalar |
The size of the gap (0-1) between envelopes when there are several densities; default 0.1 |
TRANSFORM = string token |
Transformed scale for the data (identity , log , log10 , logit , probit , cloglog , square , exp , exp10 , ilogit , iprobit , icloglog , root ); default is to use the transform defined for XAXIS |
AXISTITLE = text |
The title for the data axis; default is the name of the DATA variate |
GROUPSTITLE = text |
The title for the groups or variates axis; default is to use the name of the GROUPS factor |
WINDOW = scalar |
Window number for the graph; default 3 |
ORIENTATION = string token |
Orientation of plots (horizontal , vertical ); default vert |
METHOD = string token |
Method for plotting the density envelope (fill , line ); default fill |
SCREEN = string token |
Whether to clear screen before the plot (clear , keep , resize ); default clea |
Parameters
DATA = variates or pointers |
The data whose density is to be plotted |
---|---|
GROUPS = factors |
Factor to divide values of a single variate into groups; default * i.e. none |
TITLE = texts |
Title for graph; default uses the names of the data variates and type of plot |
Description
DXDENSITY
produces density (or violin) plots, using high-resolution graphics. The data are specified by the DATA
parameter. For a single density plot, DATA
should be set to a variate. To plot several densities, you can set DATA
to a pointer of variates. Alternatively, it can be set to a single variate, with the GROUPS
parameter then specifying a factor to identify groups of points whose densities are to be plotted separately.
The points are plotted along a line, with a kernel density smooth on either side to indicate the density of points along the line. The BANDWIDTH
option specifies the band width for the kernel smoothing; larger values make it smoother, and smaller values allow it to be rougher. The default is chosen automatically, according to the number of observations. The gap between the envelopes for different variates or groups can be defined by the GAP
option; this must be between 0 and 1 (default 0.1).
The METHOD
option controls how the density envelope is drawn around the points, either as a filled region or as a line. You can use the TITLE
parameter to supply an overall title for the plot. The AXISTITLE
and GROUPSTITLE
options can be used to supply titles for the data and groups axes respectively. The WINDOW
option specifies the number of the window to use for the plot (default 3), and the SCREEN
option controls whether the screen is cleared first, as usual (see DGRAPH
).
The data can be transformed by using the TRANSFORM
option. If this is not set, DXDENSITY
uses the setting of TRANSFORM
, defined by the XAXIS
directive for the specified WINDOW
. The available settings are the same as those of the TRANSFORM
option of XAXIS
.
The ORIENTATION
option controls whether the data axis is horizontal or vertical (default). The XAXIS
and YAXIS
directives can be used, prior to using DXDENSITY
, to set attributes of the axes of the plot in the window that is to be used. Note that, when the orientation is horizontal, the attributes of the x- and y-axes are swapped, so that the x-axis settings are always applied to the data axis.
Options: BANDWIDTH
, GAP
, TRANSFORM
, AXISTITLE
, GROUPSTITLE
, WINDOW
, ORIENTATION
, METHOD
, SCREEN
.
Parameters: DATA
, GROUPS
, TITLE
.
Action with RESTRICT
If any of the variates or factors are restricted, only the units not excluded by the restriction will be plotted.
See also
Directive: DHISTOGRAM
.
Procedures: DXYDENSITY
, DOTHISTOGRAM
, BOXPLOT
, KERNELDENSITY
, RUGPLOT
.
Commands for: Graphics.
Example
CAPTION 'DXDENSITY Example',\ !t('1) The three variates America, Asia_Oc & Other contain the',\ 'heights of volcanoes in three regions of the world.');\ STYLE=meta,plain VARIATE [VALUES=199,197,193,185,177,172,157,156,140,140,130,126,124,124,113,\ 102,100,102,94,93,89,86,83,83,83,82,77,73,70,62,58,51,51,42,40,\ 34,36,67,67,66,60,57,57,53,49,43,43,40,35,35] America & [VALUES=156,137,125,122,120,112,109,103,100,100,96,95,95,90,83,\ 81,81,81,77,75,75,73,71,71,67,66,66,64,62,60,60,60,59,58,57,\ 56,56,55,54,54,52,52,52,51,50,49,49,48,45,44,44,37,36,36,26,\ 26,24,19,11,10,41] Asia_Oc & [VALUES=134,125,114,111,100,90,80,75,49,21,21,30,60,17,19] Other DXDENSITY !P(America,Asia_Oc,Other) CAPTION !T('2) The three sets of heights are combined into a single',\ 'variate and a factor is set up to specify which values in the',\ 'combined variate came from which region.') VARIATE [VALUES=#America,#Asia_Oc,#Other] All FACTOR [LABELS=!t(America,'Asia/Oceania',Elsewhere);\ VALUES=50(1),61(2),15(3)] Region DXDENSITY [BANDWIDTH=0.35; AXISTITLE='Height of volcano'; GROUPSTITLE='Region']\ All; GROUP=Region; TITLE='Volcano height by region'