-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Description
The realm of scale limits isn't really included in {scales} at the moment, but I think the scope could be stretched a little bit to include limit helper functions.
To throw a few examples out there, here is a function to include some value into the limits. This can be convenient if you have e.g. a line plot and you want to include 0 per convention in some fields.
library(scales)
limits_include <- function(value = 0) {
force(value)
function(x) range(x, value)
}
demo_continuous(c(5, 10), limits = limits_include(-1))
#> scale_x_continuous(limits = limits_include(-1))Or make sure the range is symmetrical around some value.
limits_center <- function(center = 0) {
force(center)
function(x) c(-1, 1) * max(abs(x - center)) + center
}
demo_continuous(c(5, 10), limits = limits_center(0))
#> scale_x_continuous(limits = limits_center(0))Created on 2025-04-02 with reprex v2.1.1
davidhodge931
Metadata
Metadata
Assignees
Labels
No labels

