Stata 15 help for dotplot

[R] dotplot -- Comparative scatterplots


Dotplot of varname, with one column per value of groupvar

dotplot varname [if] [in] [, options]

Dotplot for each variable in varlist, with one column per variable

dotplot varlist [if] [in] [, options]

options Description ------------------------------------------------------------------------- Options over(groupvar) display one columnar dotplot for each value of groupvar nx(#) horizontal dot density; default is nx(0) ny(#) vertical dot density; default is ny(35) incr(#) label every # group; default is incr(1) mean|median plot a horizontal line of pluses at the mean or median bounded use minimum and maximum as boundaries bar plot horizontal dashed lines at shoulders of each group nogroup use the actual values of yvar center center the dot for each column

Plot marker_options change look of markers (color, size, etc.) marker_label_options add marker labels; change look or position

Y axis, X axis, Titles, Legend, Overall twoway_options any options other than by() documented in [G-3] twoway_options -------------------------------------------------------------------------


Graphics > Distributional graphs > Distribution dotplot


A dotplot is a scatterplot with values grouped together vertically ("binning", as in a histogram) and with plotted points separated horizontally. The aim is to display all the data for several variables or groups in one compact graphic.


+---------+ ----+ Options +----------------------------------------------------------

over(groupvar) identifies the variable for which dotplot will display one columnar dotplot for each value of groupvar. over() may not be specified in the second syntax.

nx(#) sets the horizontal dot density. A larger value of # will increase the dot density, reducing the horizontal separation between dots. This option will increase the separation between columns if two or more groups or variables are used.

ny(#) sets the vertical dot density (number of "bins" on the y axis). A larger value of # will result in more bins and a plot that is less spread out horizontally. # should be determined in conjunction with nx() to give the most pleasing appearance.

incr(#) specifies how the x axis is to be labeled. incr(1), the default, labels all groups. incr(2) labels every second group.

[mean|median] plots a horizontal line of pluses at the mean or median of each group.

bounded forces the minimum and maximum of the variable to be used as boundaries of the smallest and largest bins. It should be used with one variable whose support is not the whole of the real line and whose density does not tend to zero at the ends of its support, for example, a uniform random variable or an exponential random variable.

bar plots horizontal dashed lines at the "shoulders" of each group. The shoulders are taken to be the upper and lower quartiles unless mean had been specified; here they will be the mean plus or minus the standard deviation.

nogroup uses the actual values of yvar rather than grouping them (the default). This option may be useful if yvar takes on only a few values.

center centers the dots for each column on a hidden vertical line.

+------+ ----+ Plot +-------------------------------------------------------------

marker_options affect the rendition of markers drawn at the plotted points, including their shape, size, color, and outline; see [G-3] marker_options.

marker_label_options specify if and how the markers are to be labeled; see [G-3] marker_label_options. marker_label_options are not allowed if varlist is specified.

+-----------------------------------------+ ----+ Y axis, X axis, Titles, Legend, Overall +--------------------------

twoway_options are any of the options documented in [G-3] twoway_options, excluding by(). These include options for titling the graph (see [G-3] title_options) and for saving the graph to disk (see [G-3] saving_option).


dotplot produces a figure that has elements of a boxplot, a histogram, and a scatterplot. Like a boxplot, it is most useful for comparing the distributions of several variables or the distribution of 1 variable in several groups. Like a histogram, the figure provides a crude estimate of the density, and, as with scatterplot, each symbol (dot) represents 1 observation.


--------------------------------------------------------------------------- Setup . sysuse auto

Draw dotplots of mpg, separately for foreign and domestic cars . dotplot mpg, over(foreign)

Same as above, but change dot densities, center the dots, plot line of pluses at median, plot dashed lines at upper and lower quartiles . dotplot mpg, over(foreign) nx(20) ny(10) center median bar

--------------------------------------------------------------------------- Setup . webuse dotgr

Draw dotplots, with one column per variable . dotplot g1r1-g1r10

Same as above, but add title . dotplot g1r1-g1r10, title("Tumor volume, cu mm")


Stored results

dotplot stores the following in r():

Scalars r(nx) horizontal dot density r(ny) vertical dot density

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index