Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions R/guide-axis-theta.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ GuideAxisTheta <- ggproto(

# If the first and last positions are close together, we merge the
# labels of these positions
ends_apart <- (key$theta[n] - key$theta[1]) %% (2 * pi)
if (n > 0 && ends_apart < 0.05 && !is.null(key$.label)) {
if (n > 1L &&
(key$theta[n] - key$theta[1]) %% (2 * pi) < 0.05 &&
!is.null(key$.label)) {
if (is.expression(key$.label[[1]])) {
combined <- substitute(
paste(a, "/", b),
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-guide-axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ test_that("guide_axis_theta sets relative angle", {
expect_doppelganger("guide_axis_theta with angle adapting to theta", p)
})

test_that("guide_axis_theta with only one axis key", {
p <- ggplot(data.frame(x = "a", y = 1:3), aes(x, y)) +
geom_point() +
coord_radial()
expect_identical(get_guide_data(p, "theta")$.label, "a")
})

test_that("guide_axis_theta can be used in cartesian coordinates", {

p <- ggplot(mtcars, aes(disp, mpg)) +
Expand Down