Skip to content

Manual and identity scales for linewidth #5136

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

Merged
merged 4 commits into from
Jan 9, 2023
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
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ export(scale_linewidth_continuous)
export(scale_linewidth_date)
export(scale_linewidth_datetime)
export(scale_linewidth_discrete)
export(scale_linewidth_identity)
export(scale_linewidth_manual)
export(scale_linewidth_ordinal)
export(scale_radius)
export(scale_shape)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 (development version)

* Added `scale_linewidth_manual()` and `scale_linewidth_identity()` to support
the `linewidth` aesthetic (@teunbrand, #5050).
* Automatic breaks in `scale_*_binned()` should no longer be out-of-bounds,
and automatic limits expand to include these (@teunbrand, #5095, #5100).
* Renamed computed aesthetic in `stat_ecdf()` to `ecdf`, to prevent incorrect
Expand Down
9 changes: 9 additions & 0 deletions R/scale-identity.r
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ scale_linetype_identity <- function(..., guide = "none") {
sc
}

#' @rdname scale_identity
#' @export
scale_linewidth_identity <- function(..., guide = "none") {
sc <- continuous_scale("linewidth", "identity", identity_pal(), ...,
guide = guide, super = ScaleContinuousIdentity)

sc
}

#' @rdname scale_identity
#' @export
scale_alpha_identity <- function(..., guide = "none") {
Expand Down
7 changes: 6 additions & 1 deletion R/scale-manual.r
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ scale_linetype_manual <- function(..., values, breaks = waiver(), na.value = "bl
manual_scale("linetype", values, breaks, ..., na.value = na.value)
}

#' @rdname scale_manual
#' @export
scale_linewidth_manual <- function(..., values, breaks = waiver(), na.value = NA) {
manual_scale("linewidth", values, breaks, ..., na.value = na.value)
}

#' @rdname scale_manual
#' @export
scale_alpha_manual <- function(..., values, breaks = waiver(), na.value = NA) {
Expand All @@ -122,7 +128,6 @@ scale_discrete_manual <- function(aesthetics, ..., values, breaks = waiver()) {
manual_scale(aesthetics, values, breaks, ...)
}


manual_scale <- function(aesthetic, values = NULL, breaks = waiver(), ..., limits = NULL) {
# check for missing `values` parameter, in lieu of providing
# a default to all the different scale_*_manual() functions
Expand Down
3 changes: 3 additions & 0 deletions man/scale_identity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/scale_manual.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.