layer_boxplots: Display data with a boxplot.

Description Usage Arguments Details See Also Examples

View source: R/layer_boxplots.R

Description

This will add boxplots to a plot. The action of layer_boxplots depends on whether the x prop is continuous or categorical.

Usage

1

Arguments

vis

Visualisation to modify

...

Visual properties used to override defaults.

width

Width of each bar. When x is continuous, this controls the width in the same units as x. When x is categorical, this controls the width as a proportion of the spacing between items (default is 0.9).

Details

The upper and lower "hinges" correspond to the first and third quartiles (the 25th and 75th percentiles). This differs slightly from the method used by the boxplot function, and may be apparent with small samples. See boxplot.stats for more information on how hinge positions are calculated for boxplot.

The upper whisker extends from the hinge to the highest value that is within 1.5 * IQR of the hinge, where IQR is the inter-quartile range, or distance between the first and third quartiles. The lower whisker extends from the hinge to the lowest value within 1.5 * IQR of the hinge. Data beyond the end of the whiskers are outliers and plotted as points (as specified by Tukey).

See Also

compute_boxplot for more information on how data is transformed.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(dplyr)

# Make data set with categorical x
mtc <- mtcars
mtc$cyl <- factor(mtc$cyl)

mtc %>% ggvis(~cyl, ~mpg) %>% layer_boxplots()
# Set the width of the boxes to half the space between tick marks
mtc %>% ggvis(~cyl, ~mpg) %>% layer_boxplots(width = 0.5)

# Continuous x: boxes fill width between data values
mtcars %>% ggvis(~cyl, ~mpg) %>% layer_boxplots()
# Setting width=0.5 makes it 0.5 wide in the data space, which is 1/4 of the
# distance between data values in this particular case.
mtcars %>% ggvis(~cyl, ~mpg) %>% layer_boxplots(width = 0.5)

# Smaller outlier points
mtc %>% ggvis(~cyl, ~mpg) %>% layer_boxplots(size := 20)

rpruim/ggvis2 documentation built on May 28, 2019, 2:34 a.m.