Skip to content

Commit 94b5a16

Browse files
authored
Fix ScaleBinnedPosition for new axis implementation (#3694)
1 parent 9fdf452 commit 94b5a16

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

R/guides-axis.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ guide_train.axis <- function(guide, scale, aesthetic = NULL) {
8080
} else if (length(breaks) == 0) {
8181
guide$key <- empty_ticks
8282
} else {
83-
ticks <- new_data_frame(setNames(list(scale$map(breaks)), aesthetic))
83+
mapped_breaks <- if (scale$is_discrete()) scale$map(breaks) else breaks
84+
ticks <- new_data_frame(setNames(list(mapped_breaks), aesthetic))
8485
ticks$.value <- breaks
8586
ticks$.label <- scale$get_labels(breaks)
8687

R/scale-binned.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ scale_x_binned <- function(name = waiver(), n.breaks = 10, nice.breaks = TRUE,
2525
breaks = waiver(), labels = waiver(), limits = NULL,
2626
expand = waiver(), oob = squish, na.value = NA_real_,
2727
right = TRUE, show.limits = FALSE, trans = "identity",
28-
position = "bottom") {
28+
guide = waiver(), position = "bottom") {
2929
binned_scale(
3030
aesthetics = c("x", "xmin", "xmax", "xend", "xintercept", "xmin_final", "xmax_final", "xlower", "xmiddle", "xupper"),
3131
scale_name = "position_b", palette = identity, name = name, breaks = breaks,
3232
labels = labels, limits = limits, expand = expand, oob = oob, na.value = na.value,
3333
n.breaks = n.breaks, nice.breaks = nice.breaks, right = right, trans = trans,
34-
show.limits = show.limits, guide = "none", position = position, super = ScaleBinnedPosition
34+
show.limits = show.limits, guide = guide, position = position, super = ScaleBinnedPosition
3535
)
3636
}
3737

@@ -42,13 +42,13 @@ scale_y_binned <- function(name = waiver(), n.breaks = 10, nice.breaks = TRUE,
4242
breaks = waiver(), labels = waiver(), limits = NULL,
4343
expand = waiver(), oob = squish, na.value = NA_real_,
4444
right = TRUE, show.limits = FALSE, trans = "identity",
45-
position = "left") {
45+
guide = waiver(), position = "left") {
4646
binned_scale(
4747
aesthetics = c("y", "ymin", "ymax", "yend", "yintercept", "ymin_final", "ymax_final", "lower", "middle", "upper"),
4848
scale_name = "position_b", palette = identity, name = name, breaks = breaks,
4949
labels = labels, limits = limits, expand = expand, oob = oob, na.value = na.value,
5050
n.breaks = n.breaks, nice.breaks = nice.breaks, right = right, trans = trans,
51-
show.limits = show.limits, guide = "none", position = position, super = ScaleBinnedPosition
51+
show.limits = show.limits, guide = guide, position = position, super = ScaleBinnedPosition
5252
)
5353
}
5454

man/scale_binned.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)