geom_quartileplot: A box and whisker's plot (in the style of Tufte)

Description Usage Arguments References See Also Examples

View source: R/geom-quartileplot.R

Description

Tufte The Visual Display of Quantitative Information (Ch 6) proposes several revisions of the box plot. These variants compactly display the distribution of a continuous variable. It visualises five summary statistics: the median, two hinges (25% and 75% quartiles) and two whiskers (minimum, maximum).

Usage

1
2
3
4
geom_quartileplot(mapping = NULL, data = NULL, stat = "fivenumber",
  position = "dodge", na.rm = FALSE, show.legend = NA,
  inherit.aes = TRUE, middle.line = FALSE, whisker.line = TRUE,
  hoffset = 0.01, fatten = 1, gapsize = 0.01, ...)

Arguments

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame., and will be used as the layer data.

stat

The statistical transformation to use on the data for this layer, as a string.

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

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. It can also be a named logical vector to finely select the aesthetics to display.

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. borders().

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like color = "red" or size = 3. They may also be parameters to the paired geom/stat.

References

Tufte, Edward R. (2001) The Visual Display of Quantitative Information, Chapter 6.

See Also

geom_boxplot

geom_boxplot and geom_pointrange.

Other geom tufte: geom_rangeframe

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library("ggplot2")
library("extrafont")
extrafont::loadfonts(quiet = TRUE)
extrafont::loadfonts("postscript", quiet = TRUE)

p <- ggplot(mtcars, aes(factor(cyl), mpg))
# with a point for the median and lines for whiskers
p + geom_quartileplot()
# with a line for the interquartile range and points for whiskers
p + geom_quartileplot(middle.line = TRUE, whisker.line = FALSE)
# with a wide line for the interquartile range and lines for whiskers
p + geom_quartileplot(middle.line = TRUE, hoffset = 0, fatten = 2)
# with an offset line for the interquartile range and lines for whiskers
p + geom_quartileplot(middle.line = TRUE, hoffset = 0.01, fatten = 1)
# combined with theme_tufte
p + geom_quartileplot() +
  theme_tufte() +
  theme(axis.ticks.x = element_blank())

jrnold/ggtufte documentation built on May 4, 2019, 1:21 p.m.