Learn R Programming

ggplot2 (version 2.0.0)

geom_dotplot: Dot plot

Description

In a dot plot, the width of a dot corresponds to the bin width (or maximum width, depending on the binning algorithm), and dots are stacked, with each dot representing one observation.

Usage

geom_dotplot(mapping = NULL, data = NULL, position = "identity",
  binwidth = NULL, binaxis = "x", method = "dotdensity",
  binpositions = "bygroup", stackdir = "up", stackratio = 1,
  dotsize = 1, stackgroups = FALSE, origin = NULL, right = TRUE,
  width = 0.9, drop = FALSE, na.rm = FALSE, show.legend = NA,
  inherit.aes = TRUE, ...)

Arguments

mapping
Set of aesthetic mappings created by aes or aes_. If specified and inherit.aes = TRUE (the default), is combined with the default mapping at the top le
data
A data frame. If specified, overrides the default data frame defined at the top level of the plot.
position
Position adjustment, either as a string, or the result of a call to a position adjustment function.
binwidth
When method is "dotdensity", this specifies maximum bin width. When method is "histodot", this specifies bin width. Defaults to 1/30 of the range of the data
binaxis
The axis to bin along, "x" (default) or "y"
method
"dotdensity" (default) for dot-density binning, or "histodot" for fixed bin widths (like stat_bin)
binpositions
When method is "dotdensity", "bygroup" (default) determines positions of the bins for each group separately. "all" determines positions of the bins with all the data taken together; this is used for aligning dot stacks across multiple groups.
stackdir
which direction to stack the dots. "up" (default), "down", "center", "centerwhole" (centered, but with dots aligned)
stackratio
how close to stack the dots. Default is 1, where dots just just touch. Use smaller values for closer, overlapping dots.
dotsize
The diameter of the dots relative to binwidth, default 1.
stackgroups
should dots be stacked across groups? This has the effect that position = "stack" should have, but can't (because this geom has some odd properties).
origin
When method is "histodot", origin of first bin
right
When method is "histodot", should intervals be closed on the right (a, b], or not [a, b)
width
When binaxis is "y", the spacing of the dot stacks for dodging.
drop
If TRUE, remove all bins with zero counts
na.rm
If FALSE (the default), removes missing values with a warning. If TRUE silently removes missing values.
show.legend
logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes.
inherit.aes
If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g.
...
other arguments passed on to layer. There are three types of arguments you can use here:

  • Aesthetics: to set an aesthetic to a fixed value, likecolor = "red"orsize = 3.

Details

With dot-density binning, the bin positions are determined by the data and binwidth, which is the maximum width of each bin. See Wilkinson (1999) for details on the dot-density binning algorithm.

With histodot binning, the bins have fixed positions and fixed widths, much like a histogram.

When binning along the x axis and stacking along the y axis, the numbers on y axis are not meaningful, due to technical limitations of ggplot2. You can hide the y axis, as in one of the examples, or manually scale it to match the number of dots.