Boxplots (ggplot)

Data

diamonds is a dataset that ships with ggplot2 with observations from almost 54,000 diamonds.  Data slicing is possible by price, carat, cut, color, clarity, size, depth and table width. Boxplots are ideally suited for visualizing data variability.

Basic Boxplot Syntax

Plot60b

Boxplot Aesthetics

Boxplot aesthetics define the x input data and have several argument parameters that control box attributes: ymin,lower quartile,  middle bar statistic, upper quartile, and ymax.  Additional arguments include color, fill, linetype, shape, size, weight and alpha transparency level.

Plot60ePlot60dPlot61Plot62

Example: Fully Loaded

The default probabilities for any box plot are the standard quantiles.  Custom probabilities can be plotted using predefined data inputs and the results displayed using geom_text. Note that no outliers are plotted with ymin = 0 and ymax = 1.

Plot64b

Back | Next

Leave a Reply

Your email address will not be published. Required fields are marked *

6 − five =