Skip to content

Commit b4ca516

Browse files
committed
Don't transform NULL breaks in coord_trans.
Fixes #1422
1 parent 66147fb commit b4ca516

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ version of ggplot.
360360
* `coord_cartesian()` applies the same expansion factor to limits as for scales.
361361
You can suppress with `expand = FALSE` (#1207).
362362

363+
* `coord_trans()` now works when breaks are suppressed (#1422).
364+
363365
* `cut_number()` gives error message if the number of requested bins can
364366
be created because there are two few unique values (#1046).
365367

R/coord-transform.r

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ CoordTrans <- ggproto("CoordTrans", Coord,
130130
)
131131

132132
transform_value <- function(trans, value, range) {
133+
if (is.null(value))
134+
return(value)
133135
rescale(trans$transform(value), 0:1, range)
134136
}
135137

@@ -163,8 +165,10 @@ train_trans <- function(scale_details, limits, trans, name) {
163165
out$major_source <- transform_value(trans, out$major_source, out$range)
164166
out$minor_source <- transform_value(trans, out$minor_source, out$range)
165167

166-
out <- list(range = out$range, labels = out$labels,
167-
major = out$major_source, minor = out$minor_source)
168+
out <- list(
169+
range = out$range, labels = out$labels,
170+
major = out$major_source, minor = out$minor_source
171+
)
168172
names(out) <- paste(name, names(out), sep = ".")
169173
out
170174
}

0 commit comments

Comments
 (0)