Skip to content

Commit 31a3309

Browse files
thomasp85hadley
authored andcommitted
derive labels even if not specified in scale (#1884)
1 parent 140bb02 commit 31a3309

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

R/axis-secondary.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
103103
init = function(self, scale) {
104104
if (self$empty()) return()
105105
if (!is.formula(self$trans)) stop("transformation for secondary axes must be a formula", call. = FALSE)
106-
if (is.derived(self$name)) self$name <- scale$name
106+
if (is.derived(self$name) && !is.waive(scale$name)) self$name <- scale$name
107107
if (is.derived(self$breaks)) self$breaks <- scale$breaks
108108
if (is.derived(self$labels)) self$labels <- scale$labels
109109
},

R/layout.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Layout <- ggproto("Layout", NULL,
148148
} else {
149149
self$panel_scales$x[[1]]$sec_name()
150150
} %|W|% labels$sec.x
151+
if (is.derived(secondary)) secondary <- primary
151152
secondary <- self$panel_scales$x[[1]]$make_sec_title(secondary)
152153
list(primary = primary, secondary = secondary)[self$panel_scales$x[[1]]$axis_order()]
153154
},
@@ -160,6 +161,7 @@ Layout <- ggproto("Layout", NULL,
160161
} else {
161162
self$panel_scales$y[[1]]$sec_name()
162163
} %|W|% labels$sec.y
164+
if (is.derived(secondary)) secondary <- primary
163165
secondary <- self$panel_scales$y[[1]]$make_sec_title(secondary)
164166
list(primary = primary, secondary = secondary)[self$panel_scales$y[[1]]$axis_order()]
165167
},

0 commit comments

Comments
 (0)