Skip to content

ggplot2 3.4.0

Compare
Choose a tag to compare
@thomasp85 thomasp85 released this 07 Nov 08:19
63125db

This is a minor release focusing on tightening up the internals and ironing out
some inconsistencies in the API. The biggest change is the addition of the
linewidth aesthetic that takes of sizing the width of any line from size.
This change, while attempting to be as non-breaking as possible, has the
potential to change the look of some of your plots.

Other notable changes is a complete redo of the error and warning messaging in
ggplot2 using the cli package. Messaging is now better contextualised and it
should be easier to identify which layer an error is coming from. Last, we have
now made the switch to using the vctrs package internally which means that
support for vctrs classes as variables should improve, along with some small
gains in rendering speed.

Breaking changes

  • A linewidth aesthetic has been introduced and supersedes the size
    aesthetic for scaling the width of lines in line based geoms. size will
    remain functioning but deprecated for these geoms and it is recommended to
    update all code to reflect the new aesthetic. For geoms that have both point
    sizing and linewidth sizing (geom_pointrange() and geom_sf) size now
    only refers to sizing of points which can leads to a visual change in old
    code (@thomasp85, #3672)

  • The default line width for polygons in geom_sf() have been decreased to 0.2
    to reflect that this is usually used for demarking borders where a thinner
    line is better suited. This change was made since we already induced a
    visual change in geom_sf() with the introduction of the linewidth
    aesthetic.

  • The dot-dot notation (..var..) and stat(), which have been superseded by
    after_stat(), are now formally deprecated (@yutannihilation, #3693).

  • qplot() is now formally deprecated (@yutannihilation, #3956).

  • stage() now properly refers to the values without scale transformations for
    the stage of after_stat. If your code requires the scaled version of the
    values for some reason, you have to apply the same transformation by yourself,
    e.g. sqrt() for scale_{x,y}_sqrt() (@yutannihilation and @teunbrand, #4155).

  • Use rlang::hash() instead of digest::digest(). This update may lead to
    changes in the automatic sorting of legends. In order to enforce a specific
    legend order use the order argument in the guide. (@thomasp85, #4458)

  • referring to x in backquoted expressions with label_bquote() is no longer
    possible.

  • The ticks.linewidth and frame.linewidth parameters of guide_colourbar()
    are now multiplied with .pt like elsewhere in ggplot2. It can cause visual
    changes when these arguments are not the defaults and these changes can be
    restored to their previous behaviour by adding / .pt (@teunbrand #4314).

  • scale_*_viridis_b() now uses the full range of the viridis scales
    (@gregleleu, #4737)

New features

  • geom_col() and geom_bar() gain a new just argument. This is set to 0.5
    by default; use just = 0/just = 1 to place columns on the left/right
    of the axis breaks.
    (@wurli, #4899)

  • geom_density() and stat_density() now support bounds argument
    to estimate density with boundary correction (@echasnovski, #4013).

  • ggplot now checks during statistical transformations whether any data
    columns were dropped and warns about this. If stats intend to drop
    data columns they can declare them in the new field dropped_aes.
    (@clauswilke, #3250)

  • ... supports rlang::list2 dynamic dots in all public functions.
    (@mone27, #4764)

  • theme() now has a strip.clip argument, that can be set to "off" to
    prevent the clipping of strip text and background borders (@teunbrand, #4118)

  • geom_contour() now accepts a function in the breaks argument
    (@eliocamp, #4652).

Minor improvements and bug fixes

  • Fix a bug in position_jitter() where infinity values were dropped (@javlon,
    #4790).

  • geom_linerange() now respects the na.rm argument (#4927, @thomasp85)

  • Improve the support for guide_axis() on coord_trans()
    (@yutannihilation, #3959)

  • Added stat_align() to align data without common x-coordinates prior to
    stacking. This is now the default stat for geom_area() (@thomasp85, #4850)

  • Fix a bug in stat_contour_filled() where break value differences below a
    certain number of digits would cause the computations to fail (@thomasp85,
    #4874)

  • Secondary axis ticks are now positioned more precisely, removing small visual
    artefacts with alignment between grid and ticks (@thomasp85, #3576)

  • Improve stat_function documentation regarding xlim argument.
    (@92amartins, #4474)

  • Fix various issues with how labels, breaks, limits, and show.limits
    interact in the different binning guides (@thomasp85, #4831)

  • Automatic break calculation now squishes the scale limits to the domain
    of the transformation. This allows scale_{x/y}_sqrt() to find breaks at 0
    when appropriate (@teunbrand, #980).

  • Using multiple modified aesthetics correctly will no longer trigger warnings.
    If used incorrectly, the warning will now report the duplicated aesthetic
    instead of NA (@teunbrand, #4707).

  • aes() now supports the !!! operator in its first two arguments
    (#2675). Thanks to @yutannihilation and @teunbrand for draft
    implementations.

  • Require rlang >= 1.0.0 (@billybarc, #4797)

  • geom_violin() no longer issues "collapsing to unique 'x' values" warning
    (@bersbersbers, #4455)

  • annotate() now documents unsupported geoms (geom_abline(), geom_hline()
    and geom_vline()), and warns when they are requested (@mikmart, #4719)

  • presidential dataset now includes Trump's presidency (@bkmgit, #4703).

  • position_stack() now works fully with geom_text() (@thomasp85, #4367)

  • geom_tile() now correctly recognises missing data in xmin, xmax, ymin,
    and ymax (@thomasp85 and @sigmapi, #4495)

  • geom_hex() will now use the binwidth from stat_bin_hex() if present,
    instead of deriving it (@thomasp85, #4580)

  • geom_hex() now works on non-linear coordinate systems (@thomasp85)

  • Fixed a bug throwing errors when trying to render an empty plot with secondary
    axes (@thomasp85, #4509)

  • Axes are now added correctly in facet_wrap() when as.table = FALSE
    (@thomasp85, #4553)

  • Better compatibility of custom device functions in ggsave()
    (@thomasp85, #4539)

  • Binning scales are now more resilient to calculated limits that ends up being
    NaN after transformations (@thomasp85, #4510)

  • Strip padding in facet_grid() is now only in effect if
    strip.placement = "outside" and an axis is present between the strip and
    the panel (@thomasp85, #4610)

  • Aesthetics of length 1 are now recycled to 0 if the length of the data is 0
    (@thomasp85, #4588)

  • Setting size = NA will no longer cause guide_legend() to error
    (@thomasp85, #4559)

  • Setting stroke to NA in geom_point() will no longer impair the sizing of
    the points (@thomasp85, #4624)

  • stat_bin_2d() now correctly recognises the weight aesthetic
    (@thomasp85, #4646)

  • All geoms now have consistent exposure of linejoin and lineend parameters, and
    the guide keys will now respect these settings (@thomasp85, #4653)

  • geom_sf() now respects arrow parameter for lines (@JakeRuss, #4659)

  • Updated documentation for print.ggplot to reflect that it returns
    the original plot, not the result of ggplot_build(). (@r2evans, #4390)

  • scale_*_manual() no longer displays extra legend keys, or changes their
    order, when a named values argument has more items than the data. To display
    all values on the legend instead, use
    scale_*_manual(values = vals, limits = names(vals)). (@teunbrand, @banfai,
    #4511, #4534)

  • Updated documentation for geom_contour() to correctly reflect argument
    precedence between bins and binwidth. (@eliocamp, #4651)

  • Dots in geom_dotplot() are now correctly aligned to the baseline when
    stackratio != 1 and stackdir != "up" (@mjskay, #4614)

  • Key glyphs for geom_boxplot(), geom_crossbar(), geom_pointrange(), and
    geom_linerange() are now orientation-aware (@mjskay, #4732)

  • Updated documentation for geom_smooth() to more clearly describe effects of
    the fullrange parameter (@thoolihan, #4399).