ggplot2 2.2.1

ggplot2 2.2.0

Major new features

Subtitle and caption

Thanks to @hrbrmstr plots now have subtitles and captions, which can be set with the subtitle and caption arguments to ggtitle() and labs(). You can control their appearance with the theme settings plot.caption and plot.subtitle. The main plot title is now left-aligned to better work better with a subtitle. The caption is right-aligned (@hrbrmstr).


position_stack() and position_fill() now sort the stacking order to match grouping order. This allows you to control the order through grouping, and ensures that the default legend matches the plot (#1552, #1593). If you want the opposite order (useful if you have horizontal bars and horizontal legend), you can request reverse stacking by using position = position_stack(reverse = TRUE) (#1837).

position_stack() and position_fill() now accepts negative values which will create stacks extending below the x-axis (#1691).

position_stack() and position_fill() gain a vjust argument which makes it easy to (e.g.) display labels in the middle of stacked bars (#1821).


geom_col() was added to complement geom_bar() (@hrbrmstr). It uses stat="identity" by default, making the y aesthetic mandatory. It does not support any other stat_() and does not provide fallback support for the binwidth parameter. Examples and references in other functions were updated to demonstrate geom_col() usage.

When creating a layer, ggplot2 will warn if you use an unknown aesthetic or an unknown parameter. Compared to the previous version, this is stricter for aesthetics (previously there was no message), and less strict for parameters (previously this threw an error) (#1585).


The facet system, as well as the internal panel class, has been rewritten in ggproto. Facets are now extendable in the same manner as geoms and stats, as described in vignette("extending-ggplot2").

We have also added the following new fatures.


Unfortunately there was a major oversight in the construction of ggproto which lead to extensions capturing the super object at package build time, instead of at package run time (#1826). This problem has been fixed, but requires re-installation of all extension packages.


Continuous scales

Date time

Discrete scales

The treatment of missing values by discrete scales has been thoroughly overhauled (#1584). The underlying principle is that we can naturally represent missing values on discrete variables (by treating just like another level), so by default we should.

This principle applies to:

And to all scales (both position and non-position.)

Compared to the previous version of ggplot2, there are three main changes:

  1. scale_x_discrete() and scale_y_discrete() always show discrete NA, regardless of their source

  2. If present, NAs are shown in discete legends.

  3. All discrete scales gain a na.translate argument that allows you to control whether NAs are translated to something that can be visualised, or should be left as missing. Note that if you don't translate (i.e. na.translate = FALSE) the missing values will passed on to the layer, which will warning that it's dropping missing values. To suppress the warnings, you'll also need to add na.rm = TRUE to the layer call.

There were also a number of other smaller changes


There were a number of tweaks to the theme elements that control legends:

Bug fixes and minor improvements

ggplot2 2.1.0

New features

Bug fixes

ggplot2 2.0.0

Major changes


There is now an official mechanism for defining Stats, Geoms, and Positions in other packages. See vignette("extending-ggplot2") for details.


Deprecated features

A number of geoms have been renamed to be internally consistent:

All defunct functions have been removed.

Default appearance

New and updated themes


The facet labelling system was updated with many new features and a more flexible interface (@lionel-). It now works consistently across grid and wrap facets. The most important user visible changes are:

The labellers (such as label_value() or label_both()) also get some new features:

As a consequence of these changes, referring to x in backquoted expressions is deprecated.

On the programming side, the labeller API has been rewritten in order to offer more control when facetting over multiple factors (e.g. with formulae such as ~cyl + am). This also means that if you have written custom labellers, you will need to update them for this version of ggplot.



Bug fixes and minor improvements