ggplot2 3.4.0
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 thesize
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()
andgeom_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 ingeom_sf()
with the introduction of thelinewidth
aesthetic. -
The dot-dot notation (
..var..
) andstat()
, 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 ofafter_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()
forscale_{x,y}_sqrt()
(@yutannihilation and @teunbrand, #4155). -
Use
rlang::hash()
instead ofdigest::digest()
. This update may lead to
changes in the automatic sorting of legends. In order to enforce a specific
legend order use theorder
argument in the guide. (@thomasp85, #4458) -
referring to
x
in backquoted expressions withlabel_bquote()
is no longer
possible. -
The
ticks.linewidth
andframe.linewidth
parameters ofguide_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()
andgeom_bar()
gain a newjust
argument. This is set to0.5
by default; usejust = 0
/just = 1
to place columns on the left/right
of the axis breaks.
(@wurli, #4899) -
geom_density()
andstat_density()
now supportbounds
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 fielddropped_aes
.
(@clauswilke, #3250) -
...
supportsrlang::list2
dynamic dots in all public functions.
(@mone27, #4764) -
theme()
now has astrip.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 thebreaks
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 thena.rm
argument (#4927, @thomasp85) -
Improve the support for
guide_axis()
oncoord_trans()
(@yutannihilation, #3959) -
Added
stat_align()
to align data without common x-coordinates prior to
stacking. This is now the default stat forgeom_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 regardingxlim
argument.
(@92amartins, #4474) -
Fix various issues with how
labels
,breaks
,limits
, andshow.limits
interact in the different binning guides (@thomasp85, #4831) -
Automatic break calculation now squishes the scale limits to the domain
of the transformation. This allowsscale_{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 ofNA
(@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()
andgeom_vline()
), and warns when they are requested (@mikmart, #4719) -
presidential
dataset now includes Trump's presidency (@bkmgit, #4703). -
position_stack()
now works fully withgeom_text()
(@thomasp85, #4367) -
geom_tile()
now correctly recognises missing data inxmin
,xmax
,ymin
,
andymax
(@thomasp85 and @sigmapi, #4495) -
geom_hex()
will now use the binwidth fromstat_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()
whenas.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 causeguide_legend()
to error
(@thomasp85, #4559) -
Setting
stroke
toNA
ingeom_point()
will no longer impair the sizing of
the points (@thomasp85, #4624) -
stat_bin_2d()
now correctly recognises theweight
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 respectsarrow
parameter for lines (@JakeRuss, #4659) -
Updated documentation for
print.ggplot
to reflect that it returns
the original plot, not the result ofggplot_build()
. (@r2evans, #4390) -
scale_*_manual()
no longer displays extra legend keys, or changes their
order, when a namedvalues
argument has more items than the data. To display
allvalues
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 betweenbins
andbinwidth
. (@eliocamp, #4651) -
Dots in
geom_dotplot()
are now correctly aligned to the baseline when
stackratio != 1
andstackdir != "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
thefullrange
parameter (@thoolihan, #4399).