ggplot2 3.3.0
This is a minor release but does contain a range of substantial new features,
along with the standard bug fixes. The release contains a few visual breaking
changes, along with breaking changes for extension developers due to a shift in
internal representation of the position scales and their axes. No user breaking
changes are included.
This release also adds Dewey Dunnington (@paleolimbot) to the core team.
Breaking changes
There are no user-facing breaking changes, but a change in some internal
representations that extension developers may have relied on, along with a few
breaking visual changes which may cause visual tests in downstream packages to
fail.
-
The
panel_paramsfield in theLayoutnow contains a list of list of
ViewScaleobjects, describing the trained coordinate system scales, instead
of the list object used before. Any extensions that use this field will likely
break, as will unit tests that checks aspects of this. -
element_text()now issues a warning when vectorized arguments are provided,
as incolour = c("red", "green", "blue"). Such use is discouraged and not
officially supported (@clauswilke, #3492). -
Changed
theme_grey()setting for legend key so that it creates no border
(NA) rather than drawing a white one. (@annennenne, #3180) -
geom_ribbon()now draws separate lines for the upper and lower intervals if
colouris mapped. Similarly,geom_area()andgeom_density()now draw
the upper lines only in the same case by default. If you want old-style full
stroking, useoutline.type = "full"(@yutannihilation, #3503 / @thomasp85, #3708).
New features
-
The evaluation time of aesthetics can now be controlled to a finer degree.
after_stat()supersedes the use ofstat()and..var..-notation, and is
joined byafter_scale()to allow for mapping to scaled aesthetic values.
Remapping of the same aesthetic is now supported withstage(), so you can
map a data variable to a stat aesthetic, and remap the same aesthetic to
something else after statistical transformation (@thomasp85, #3534) -
All
coord_*()functions withxlimandylimarguments now accept
vectors withNAas a placeholder for the minimum or maximum value
(e.g.,ylim = c(0, NA)would zoom the y-axis from 0 to the
maximum value observed in the data). This mimics the behaviour
of thelimitsargument in continuous scale functions
(@paleolimbot, #2907). -
Allowed reversing of discrete scales by re-writing
get_limits()
(@AnneLyng, #3115) -
All geoms and stats that had a direction (i.e. where the x and y axes had
different interpretation), can now freely choose their direction, instead of
relying oncoord_flip(). The direction is deduced from the aesthetic
mapping, but can also be specified directly with the neworientation
argument (@thomasp85, #3506). -
Position guides can now be customized using the new
guide_axis(), which can
be passed to positionscale_*()functions or viaguides(). The new axis
guide (guide_axis()) comes with argumentscheck.overlap(automatic removal
of overlapping labels),angle(easy rotation of axis labels), and
n.dodge(dodge labels into multiple rows/columns) (@paleolimbot, #3322). -
A new scale type has been added, that allows binning of aesthetics at the
scale level. It has versions for both position and non-position aesthetics and
comes with two new guides (guide_binsandguide_coloursteps)
(@thomasp85, #3096) -
scale_x_continuous()andscale_y_continuous()gains ann.breaksargument
guiding the number of automatic generated breaks (@thomasp85, #3102) -
Added
stat_contour_filled()andgeom_contour_filled(), which compute
and draw filled contours of gridded data (@paleolimbot, #3044).
geom_contour()andstat_contour()now use the isoband package
to compute contour lines. Thecompleteparameter (which was undocumented
and has been unused for at least four years) was removed (@paleolimbot, #3044). -
Themes have gained two new parameters,
plot.title.positionand
plot.caption.position, that can be used to customize how plot
title/subtitle and plot caption are positioned relative to the overall plot
(@clauswilke, #3252).
Extensions
-
Geomnow gains asetup_params()method in line with the other ggproto
classes (@thomasp85, #3509) -
The newly added function
register_theme_elements()now allows developers
of extension packages to define their own new theme elements and place them
into the ggplot2 element tree (@clauswilke, #2540).
Minor improvements and bug fixes
-
coord_trans()now draws second axes and acceptsxlim,ylim,
andexpandarguments to bring it up to feature parity with
coord_cartesian(). Thextransandytransarguments that were
deprecated in version 1.0.1 in favour ofxandy
were removed (@paleolimbot, #2990). -
coord_trans()now calculates breaks using the expanded range
(previously these were calculated using the unexpanded range,
which resulted in differences between plots made withcoord_trans()
and those made withcoord_cartesian()). The expansion for discrete axes
incoord_trans()was also updated such that it behaves identically
to that incoord_cartesian()(@paleolimbot, #3338). -
expand_scale()was deprecated in favour ofexpansion()for setting
theexpandargument ofxandyscales (@paleolimbot). -
geom_abline(),geom_hline(), andgeom_vline()now issue
more informative warnings when supplied with set aesthetics
(i.e.,slope,intercept,yintercept, and/orxintercept)
and mapped aesthetics (i.e.,dataand/ormapping). -
Fix a bug in
geom_raster()that squeezed the image when it went outside
scale limits (#3539, @thomasp85) -
geom_sf()now determines the legend type automatically (@microly, #3646). -
geom_sf()now removes rows that can't be plotted due toNAaesthetics
(#3546, @thomasp85) -
geom_sf()now applies alpha to linestring geometries
(#3589, @yutannihilation). -
Added function
ggplot_add.by()for lists created withby(), allowing such
lists to be added to ggplot objects (#2734, @Maschette) -
ggplot2 no longer depends on reshape2, which means that it no longer
(recursively) needs plyr, stringr, or stringi packages. -
Increase the default
nbinofguide_colourbar()to place the ticks more
precisely (#3508, @yutannihilation). -
manual_scale()now matchesvalueswith the order ofbreakswhenever
valuesis an unnamed vector. Previously, unnamedvalueswould match with
the limits of the scale and ignore the order of anybreaksprovided. Note
that this may change the appearance of plots that previously relied on the
unordered behaviour (#2429, @idno0001). -
scale_manual_*(limits = ...)now actually limits the scale (#3262,
@yutannihilation). -
Fix a bug when
show.legendis a named logical vector
(#3461, @yutannihilation). -
Added weight aesthetic option to
stat_density()and made scaling of
weights the default (@annennenne, #2902) -
stat_density2d()can now take anadjustparameter to scale the default
bandwidth. (#2860, @haleyjeppson) -
stat_smooth()usesREMLby default, ifmethod = "gam"and
gam's method is not specified (@ikosmidis, #2630). -
stacking text when calculating the labels and the y axis with
stat_summary()now works (@ikosmidis, #2709) -
stat_summary()and related functions now support rlang-style lambda functions
(#3568, @dkahle). -
The data mask pronoun,
.data, is now stripped from default labels. -
Addition of partial themes to plots has been made more predictable;
stepwise addition of individual partial themes is now equivalent to
addition of multple theme elements at once (@clauswilke, #3039). -
Facets now don't fail even when some variable in the spec are not available
in all layers (@yutannihilation, #2963).