Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use 'transform' argument #115

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ggpattern
Type: Package
Title: 'ggplot2' Pattern Geoms
Version: 1.1.0-5
Version: 1.1.0-6
Authors@R: c(person("Mike", "FC", role = "aut"),
person("Trevor L.", "Davis", role = c("aut", "cre"),
email = "[email protected]",
Expand All @@ -19,6 +19,7 @@ Imports:
glue,
grid,
gridpattern (>= 1.2.0),
lifecycle,
rlang,
scales,
Suggests:
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ importFrom(grDevices,col2rgb)
importFrom(grDevices,dev.off)
importFrom(grDevices,png)
importFrom(grDevices,rgb)
importFrom(lifecycle,deprecated)
importFrom(stats,setNames)
importFrom(utils,head)
importFrom(utils,tail)
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
actual aspect ratio (instead of 1).
This may cause your legends to `geom_sf_pattern()` to look different.

## Deprecated features

* In line with upstream changes in `{ggplot2}` the `trans` argument has been deprecated in various scales functions.
Use the new `transform` argument instead (#113).

## New features

* `geom_bar_pattern()` and `geom_col_pattern()` now accept argument `just`.
Expand All @@ -26,6 +31,7 @@

* `draw_key_boxplot_pattern()`, `draw_key_crossbar_pattern()`, and `draw_key_polygon_pattern()` `aspect_ratio` argument
now defaults to `get_aspect_ratio()`.
* Several (continuous) scales now have an `...` argument which will be passed to `ggplot2::continuous_scale()`.

# ggpattern 1.0.1

Expand Down
31 changes: 11 additions & 20 deletions R/scale-pattern-size.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-----------------------------------------------------------------------------
#' Scales for area or radius
#'
#' @param name,breaks,labels,limits,trans,guide See \code{ggplot2::scale_size} for more information
#' @param name,breaks,labels,limits,trans,guide,...,transform See [ggplot2::scale_size()] for more information
#' @param range a numeric vector of length 2 that specifies the minimum and
#' maximum size of the plotting symbol after transformation.
#' @return A [ggplot2::Scale] object.
Expand Down Expand Up @@ -33,10 +33,17 @@
#-----------------------------------------------------------------------------
scale_pattern_size_continuous <- function(name = waiver(), breaks = waiver(), labels = waiver(),
limits = NULL, range = c(1, 6),
trans = "identity", guide = "legend") {
trans = deprecated(), guide = "legend",
..., transform = "identity") {
if (lifecycle::is_present(trans)) {{
lifecycle::deprecate_warn('1.1.1',
'scale_pattern_size_continuous(trans)',
'scale_pattern_size_continuous(transform)')
transform <- trans
}}
continuous_scale("pattern_size", palette = area_pal(range), name = name,
breaks = breaks, labels = labels, limits = limits, trans = trans,
guide = guide)
breaks = breaks, labels = labels, limits = limits, transform = transform,
guide = guide, ...)
}

#-----------------------------------------------------------------------------
Expand All @@ -45,31 +52,15 @@ scale_pattern_size_continuous <- function(name = waiver(), breaks = waiver(), la
#-----------------------------------------------------------------------------
scale_pattern_size <- scale_pattern_size_continuous


# #-----------------------------------------------------------------------------
# #' @rdname scale_pattern_size_continuous
# #' @export
# #-----------------------------------------------------------------------------
# scale_size_binned <- function(name = waiver(), breaks = waiver(), labels = waiver(),
# limits = NULL, range = c(1, 6), n.breaks = NULL,
# nice.breaks = TRUE, trans = "identity", guide = "bins") {
# binned_scale("size", palette = area_pal(range), name = name,
# breaks = breaks, labels = labels, limits = limits, trans = trans,
# n.breaks = n.breaks, nice.breaks = nice.breaks, guide = guide)
# }


#-----------------------------------------------------------------------------
#' @rdname scale_pattern_size_continuous
#' @export
#' @usage NULL
#-----------------------------------------------------------------------------
scale_pattern_size_discrete <- function(...) {
# warn("Using pattern_size for a discrete variable is not advised.")
scale_pattern_size_ordinal(...)
}


#-----------------------------------------------------------------------------
#' @rdname scale_pattern_size_continuous
#' @export
Expand Down
Loading
Loading