Skip to content

Commit

Permalink
Merge branch 'main' into fix/zero-range-transformed-scale
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand authored Sep 12, 2023
2 parents 3cfb20e + 5da2d30 commit a9d87dc
Show file tree
Hide file tree
Showing 145 changed files with 2,792 additions and 791 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: ggplot2
Version: 3.4.2.9000
Version: 3.4.3.9000
Title: Create Elegant Data Visualisations Using the Grammar of Graphics
Authors@R: c(
person("Hadley", "Wickham", , "hadley@posit.co", role = "aut",
Expand Down Expand Up @@ -181,6 +181,7 @@ Collate:
'guide-colorsteps.R'
'layer.R'
'guide-none.R'
'guide-old.R'
'guides-.R'
'guides-grid.R'
'hexbin.R'
Expand Down
12 changes: 12 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ S3method(grobWidth,absoluteGrob)
S3method(grobWidth,zeroGrob)
S3method(grobX,absoluteGrob)
S3method(grobY,absoluteGrob)
S3method(guide_gengrob,default)
S3method(guide_geom,default)
S3method(guide_merge,default)
S3method(guide_train,default)
S3method(guide_transform,default)
S3method(heightDetails,titleGrob)
S3method(heightDetails,zeroGrob)
S3method(interleave,default)
Expand Down Expand Up @@ -211,6 +216,7 @@ export(GuideColourbar)
export(GuideColoursteps)
export(GuideLegend)
export(GuideNone)
export(GuideOld)
export(Layout)
export(Position)
export(PositionDodge)
Expand Down Expand Up @@ -416,8 +422,13 @@ export(guide_colorbar)
export(guide_colorsteps)
export(guide_colourbar)
export(guide_coloursteps)
export(guide_gengrob)
export(guide_geom)
export(guide_legend)
export(guide_merge)
export(guide_none)
export(guide_train)
export(guide_transform)
export(guides)
export(has_flipped_aes)
export(is.Coord)
Expand Down Expand Up @@ -451,6 +462,7 @@ export(mean_se)
export(median_hilow)
export(merge_element)
export(new_guide)
export(old_guide)
export(panel_cols)
export(panel_rows)
export(position_dodge)
Expand Down
86 changes: 75 additions & 11 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,52 @@
* `ScaleContinuous$get_breaks()` now only calls `scales::zero_range()` on limits
in transformed space, rather than in data space (#5304).

* Scales throw more informative messages (@teunbrand, #4185, #4258)

* The `scale_name` argument in `continuous_scale()`, `discrete_scale()` and
`binned_scale()` is soft-deprecated (@teunbrand, #1312).

* In `theme()`, some elements can be specified with `rel()` to inherit from
`unit`-class objects in a relative fashion (@teunbrand, #3951).

* `stat_ydensity()` with incomplete groups calculates the default `width`
parameter more stably (@teunbrand, #5396)

* `geom_boxplot()` gains a new argument, `staplewidth` that can draw staples
at the ends of whiskers (@teunbrand, #5126)

* The `size` argument in `annotation_logticks()` has been deprecated in favour
of the `linewidth` argument (#5292).

* `geom_boxplot()` gains an `outliers` argument to switch outliers on or off,
in a manner that does affects the scale range. For hiding outliers that does
not affect the scale range, you can continue to use `outlier.shape = NA`
(@teunbrand, #4892).

* Binned scales now treat `NA`s in limits the same way continuous scales do
(#5355).

* Binned scales work better with `trans = "reverse"` (#5355).

* The `legend.text.align` and `legend.title.align` arguments in `theme()` are
deprecated. The `hjust` setting of the `legend.text` and `legend.title`
elements continues to fulfil the role of text alignment (@teunbrand, #5347).

* Integers are once again valid input to theme arguments that expect numeric
input (@teunbrand, #5369)

* Nicer error messages for xlim/ylim arguments in coord-* functions
(@92amartins, #4601, #5297).

* `coord_sf()` now uses customisable guides provided in the scales or
`guides()` function (@teunbrand).

* Legends in `scale_*_manual()` can show `NA` values again when the `values` is
a named vector (@teunbrand, #5214, #5286).

* `scale_*_manual()` with a named `values` argument now emits a warning when
none of those names match the values found in the data (@teunbrand, #5298).

* `coord_munch()` can now close polygon shapes (@teunbrand, #3271)

* You can now omit either `xend` or `yend` from `geom_segment()` as only one
Expand All @@ -21,6 +67,13 @@
in ggproto. The axes and legends now inherit from a <Guide> class, which makes
them extensible in the same manner as geoms, stats, facets and coords
(#3329, @teunbrand). In addition, the following changes were made:
* A fallback for old S3 guides is encapsulated in the `GuideOld` ggproto
class, which mostly just calls the old S3 generics.
* While the S3 guide generics are still in place, the S3 methods for
`guide_train()`, `guide_merge()`, `guide_geom()`, `guide_transform()`,
`guide_gengrob()` have been superseded by the respective ggproto methods.
In practise, this will mean that `NextMethod()` or sub-classing ggplot2's
guides with the S3 system will no longer work.
* Styling theme parts of the guide now inherit from the plot's theme
(#2728).
* Styling non-theme parts of the guides accept <element> objects, so that
Expand All @@ -39,6 +92,12 @@
* More informative error for mismatched
`direction`/`theme(legend.direction = ...)` arguments (#4364, #4930).
* `guide_coloursteps()` and `guide_bins()` sort breaks (#5152).
* `guide_axis()` gains a `cap` argument that can be used to trim the
axis line to extreme breaks (#4907).
* `guide_colourbar()` and `guide_coloursteps()` merge properly when one
of aesthetics is dropped (#5324).
* Fixed regression in `guide_legend()` where the `linewidth` key size
wasn't adapted to the width of the lines (#5160).

* `geom_label()` now uses the `angle` aesthetic (@teunbrand, #2785)
* 'lines' units in `geom_label()`, often used in the `label.padding` argument,
Expand Down Expand Up @@ -72,6 +131,11 @@
* A stacking bug in `stat_align()` was fixed (@teunbrand, #5176).
* `stat_contour()` and `stat_contour_filled()` now warn about and remove
duplicated coordinates (@teunbrand, #5215).
* Improve performance of layers without positional scales (@zeehio, #4990)

# ggplot2 3.4.3
This hotfix release addresses a version comparison change in r-devel. There are
no user-facing or breaking changes.

# ggplot2 3.4.2
This is a hotfix release anticipating changes in r-devel, but folds in upkeep
Expand Down Expand Up @@ -488,7 +552,7 @@ small selection of feature refinements.
(@thomasp85, #4149)

* Fix bug in `scale_[x|y]_date()` where custom breaks functions that resulted in
fracional dates would get misaligned (@thomasp85, #3965)
fractional dates would get misaligned (@thomasp85, #3965)

* Fix bug in `scale_[x|y]_datetime()` where a specified timezone would be
ignored by the scale (@thomasp85, #4007)
Expand All @@ -514,7 +578,7 @@ small selection of feature refinements.
and plots are faceted with multi-layered strips (@teunbrand, #4384).

* Using `theme(aspect.ratio = ...)` together with free space in `facet_grid()`
now crrectly throws an error (@thomasp85, #3834)
now correctly throws an error (@thomasp85, #3834)

* Fixed a bug in `labeller()` so that `.default` is passed to `as_labeller()`
when labellers are specified by naming faceting variables. (@waltersom, #4031)
Expand Down Expand Up @@ -783,7 +847,7 @@ fixing some unit tests that broke due to upstream changes.
with ribbons that spanned `y = 0` (#3471)
* Using `qplot()` with a single positional aesthetic will no longer title the
non-specified scale as `"NULL"` (#3473)
* Fixes unit tests for sf graticule labels caused by chages to sf
* Fixes unit tests for sf graticule labels caused by changes to sf

# ggplot2 3.2.0

Expand Down Expand Up @@ -1129,7 +1193,7 @@ accompanying issue #2890.
* Error: `data` must be uniquely named but has duplicate columns

If layer data contains columns with identical names an error will be
thrown. In earlier versions the first occuring column was chosen silently,
thrown. In earlier versions the first occurring column was chosen silently,
potentially masking that the wrong data was chosen.

* Error: Aesthetics must be either length 1 or the same as the data
Expand Down Expand Up @@ -1617,7 +1681,7 @@ 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.
We have also added the following new features.
* `facet_grid()` and `facet_wrap()` now allow expressions in their faceting
formulas (@DanRuderman, #1596).
Expand Down Expand Up @@ -1667,7 +1731,7 @@ re-installation of all extension packages.
### Date time
* `scale_*_datetime()` now supports time zones. It will use the timezone
attached to the varaible by default, but can be overridden with the
attached to the variable by default, but can be overridden with the
`timezone` argument.
* New `scale_x_time()` and `scale_y_time()` generate reasonable default
Expand All @@ -1693,7 +1757,7 @@ 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
1. If present, `NA`s are shown in discete legends.
1. If present, `NA`s are shown in discrete legends.
1. All discrete scales gain a `na.translate` argument that allows you to
control whether `NA`s are translated to something that can be visualised,
Expand Down Expand Up @@ -1774,7 +1838,7 @@ There were a number of tweaks to the theme elements that control legends:

* `geom_contour()` more clearly describes what inputs it needs (#1577).

* `geom_curve()` respects the `lineend` paramater (#1852).
* `geom_curve()` respects the `lineend` parameter (#1852).

* `geom_histogram()` and `stat_bin()` understand the `breaks` parameter once
more. (#1665). The floating point adjustment for histogram bins is now
Expand Down Expand Up @@ -2261,7 +2325,7 @@ version of ggplot.
inline with the 2nd edition of the ggplot2 box, which minimises the use of
`qplot()` in favour of `ggplot()`.

* Tighly linked geoms and stats (e.g. `geom_boxplot()` and `stat_boxplot()`)
* Tightly linked geoms and stats (e.g. `geom_boxplot()` and `stat_boxplot()`)
are now documented in the same file so you can see all the arguments in one
place. Variations of the same idea (e.g. `geom_path()`, `geom_line()`, and
`geom_step()`) are also documented together.
Expand Down Expand Up @@ -2364,7 +2428,7 @@ version of ggplot.
* `geom_segment()` annotations were not transforming with scales
(@BrianDiggs, #859).
* `geom_smooth()` is no longer so chatty. If you want to know what the deafult
* `geom_smooth()` is no longer so chatty. If you want to know what the default
smoothing method is, look it up in the documentation! (#1247)
* `geom_violin()` now has the ability to draw quantile lines (@DanRuderman).
Expand Down Expand Up @@ -2396,7 +2460,7 @@ version of ggplot.
* You can now suppress the appearance of an axis/legend title (and the space
that would allocated for it) with `NULL` in the `scale_` function. To
use the default lable, use `waiver()` (#1145).
use the default label, use `waiver()` (#1145).
* Position adjustments no longer warn about potentially varying ranges
because the problem rarely occurs in practice and there are currently a
Expand Down
23 changes: 15 additions & 8 deletions R/annotation-logticks.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
#' using `scale_y_log10()`. It should be `FALSE` when using
#' `coord_trans(y = "log10")`.
#' @param colour Colour of the tick marks.
#' @param size Thickness of tick marks, in mm.
#' @param linewidth Thickness of tick marks, in mm.
#' @param linetype Linetype of tick marks (`solid`, `dashed`, etc.)
#' @param alpha The transparency of the tick marks.
#' @param color An alias for `colour`.
#' @param ... Other parameters passed on to the layer
#' @param size `r lifecycle::badge("deprecated")`
#'
#' @export
#' @seealso [scale_y_continuous()], [scale_y_log10()] for log scale
Expand Down Expand Up @@ -81,11 +82,17 @@
#' )
annotation_logticks <- function(base = 10, sides = "bl", outside = FALSE, scaled = TRUE,
short = unit(0.1, "cm"), mid = unit(0.2, "cm"), long = unit(0.3, "cm"),
colour = "black", size = 0.5, linetype = 1, alpha = 1, color = NULL, ...)
colour = "black", linewidth = 0.5, linetype = 1, alpha = 1, color = NULL, ...,
size = deprecated())
{
if (!is.null(color))
colour <- color

if (lifecycle::is_present(size)) {
deprecate_soft0("3.5.0", I("Using the `size` aesthetic in this geom"), I("`linewidth`"))
linewidth <- linewidth %||% size
}

layer(
data = dummy_data(),
mapping = NULL,
Expand All @@ -103,7 +110,7 @@ annotation_logticks <- function(base = 10, sides = "bl", outside = FALSE, scaled
mid = mid,
long = long,
colour = colour,
size = size,
linewidth = linewidth,
linetype = linetype,
alpha = alpha,
...
Expand Down Expand Up @@ -163,14 +170,14 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
ticks$x_b <- with(data, segmentsGrob(
x0 = unit(xticks$x, "native"), x1 = unit(xticks$x, "native"),
y0 = unit(xticks$start, "cm"), y1 = unit(xticks$end, "cm"),
gp = gpar(col = alpha(colour, alpha), lty = linetype, lwd = size * .pt)
gp = gpar(col = alpha(colour, alpha), lty = linetype, lwd = linewidth * .pt)
))
}
if (grepl("t", sides) && nrow(xticks) > 0) {
ticks$x_t <- with(data, segmentsGrob(
x0 = unit(xticks$x, "native"), x1 = unit(xticks$x, "native"),
y0 = unit(1, "npc") - unit(xticks$start, "cm"), y1 = unit(1, "npc") - unit(xticks$end, "cm"),
gp = gpar(col = alpha(colour, alpha), lty = linetype, lwd = size * .pt)
gp = gpar(col = alpha(colour, alpha), lty = linetype, lwd = linewidth * .pt)
))
}
}
Expand Down Expand Up @@ -201,22 +208,22 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
ticks$y_l <- with(data, segmentsGrob(
y0 = unit(yticks$y, "native"), y1 = unit(yticks$y, "native"),
x0 = unit(yticks$start, "cm"), x1 = unit(yticks$end, "cm"),
gp = gpar(col = alpha(colour, alpha), lty = linetype, lwd = size * .pt)
gp = gpar(col = alpha(colour, alpha), lty = linetype, lwd = linewidth * .pt)
))
}
if (grepl("r", sides) && nrow(yticks) > 0) {
ticks$y_r <- with(data, segmentsGrob(
y0 = unit(yticks$y, "native"), y1 = unit(yticks$y, "native"),
x0 = unit(1, "npc") - unit(yticks$start, "cm"), x1 = unit(1, "npc") - unit(yticks$end, "cm"),
gp = gpar(col = alpha(colour, alpha), lty = linetype, lwd = size * .pt)
gp = gpar(col = alpha(colour, alpha), lty = linetype, lwd = linewidth * .pt)
))
}
}

gTree(children = inject(gList(!!!ticks)))
},

default_aes = aes(colour = "black", size = 0.5, linetype = 1, alpha = 1)
default_aes = aes(colour = "black", linewidth = 0.5, linetype = 1, alpha = 1)
)


Expand Down
2 changes: 1 addition & 1 deletion R/autolayer.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ autolayer <- function(object, ...) {

#' @export
autolayer.default <- function(object, ...) {
cli::cli_abort("No autolayer method avialable for {.cls {class(object)[1]}} objects")
cli::cli_abort("No autolayer method available for {.cls {class(object)[1]}} objects")
}
2 changes: 1 addition & 1 deletion R/axis-secondary.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
#' @export
sec_axis <- function(trans = NULL, name = waiver(), breaks = waiver(), labels = waiver(),
guide = waiver()) {
# sec_axis() historically accpeted two-sided formula, so be permissive.
# sec_axis() historically accepted two-sided formula, so be permissive.
if (length(trans) > 2) trans <- trans[c(1,3)]

trans <- as_function(trans)
Expand Down
4 changes: 2 additions & 2 deletions R/backports.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Backport fix from R 3.3:
# https://github.com/wch/r-source/commit/4efc81c98d262f93de9e7911aaa910f5c63cd00f
if (getRversion() < 3.3) {
if (getRversion() < "3.3") {
absolute.units <- getFromNamespace("absolute.units", "grid")
absolute.units.unit <- getFromNamespace("absolute.units.unit", "grid")
absolute.units.unit.list <- getFromNamespace("absolute.units.unit.list", "grid")
Expand All @@ -18,6 +18,6 @@ if (getRversion() < 3.3) {
on_load(backport_unit_methods())

# isFALSE() is available on R (>=3.5)
if (getRversion() < 3.5) {
if (getRversion() < "3.5") {
isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
}
6 changes: 3 additions & 3 deletions R/compat-plyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ id_var <- function(x, drop = FALSE) {
#' Properties:
#' - `order(id)` is equivalent to `do.call(order, df)`
#' - rows containing the same data have the same value
#' - if `drop = FALSE` then room for all possibilites
#' - if `drop = FALSE` then room for all possibilities
#'
#' @param .variables list of variables
#' @param drop Should unused factor levels be dropped?
Expand Down Expand Up @@ -124,10 +124,10 @@ id <- function(.variables, drop = FALSE) {
res
}
}
#' Count number of occurences for each unique combination of variables
#' Count number of occurrences for each unique combination of variables
#'
#' Each unique combination of the variables in `df` given by `vars` will be
#' identified and their occurences counted. If `wt_var` is given the counts will
#' identified and their occurrences counted. If `wt_var` is given the counts will
#' be weighted by the values in this column.
#'
#' @param df A data.frame
Expand Down
Loading

0 comments on commit a9d87dc

Please sign in to comment.