Skip to content

Commit f74891c

Browse files
committed
Allow setting one of the limits of scale
Implements setting of only one limit of a continuous scale by specifying NA for the limit which you don't want to set.
1 parent 9b8dc05 commit f74891c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

R/limits.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ limits <- function(lims, var) UseMethod("limits")
4747
#' @export
4848
limits.numeric <- function(lims, var) {
4949
stopifnot(length(lims) == 2)
50-
if (lims[1] > lims[2]) {
50+
if (sum(is.na(lims)) == 0 &lims[1] > lims[2]) {
5151
trans <- "reverse"
5252
} else {
5353
trans <- "identity"

R/scale-.r

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ scale_limits <- function(scale) {
298298

299299
#' @export
300300
scale_limits.default <- function(scale) {
301-
scale$limits %||% scale$range$range
301+
if(!is.null(scale$limits))
302+
ifelse(!is.na(scale$limits),scale$limits,scale$range$range)
303+
else scale$range$range
302304
}
303305

304306
# @kohske

0 commit comments

Comments
 (0)