- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
Closed
Description
The following code worked with the current version 3.3.6 on CRAN but failed in the dev version (R 4.1.3 x64 on Windows 10). I am wondering what commit broke it? Thanks!
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.3.6.9000'
groups <- LETTERS[1:3]
df <- data.frame(
  x = rep(1:10, 3),
  y = rnorm(30),
  group = rep(groups, each = 10)
)
df
#>     x           y group
#> 1   1 -0.38073967     A
#> 2   2  0.67451767     A
#> 3   3  0.02328174     A
#> 4   4  1.29683640     A
#> 5   5 -1.70061129     A
#> 6   6 -1.66503519     A
#> 7   7  0.18308837     A
#> 8   8 -0.89437196     A
#> 9   9 -0.37365461     A
#> 10 10 -1.44795542     A
#> 11  1 -0.20990950     B
#> 12  2  0.24870379     B
ggplot(df, aes(x, y, colour = group, linetype = group)) +
  geom_line() +
  scale_x_reverse(breaks = rev(c(10, 5, 2, 1)),
                  labels = rev(c("10", "5", "", "1"))) +
  scale_colour_manual(
    "",
    values = setNames(c("blue", "green", "red"), groups)
  ) +
  scale_linetype_manual(
    "",
    values = setNames(c("solid", "dashed", "dotted"), groups)
  )
#> Error in `get_labels()`:
#> ! `breaks` and `labels` are different lengthsrlang::last_error()
---
Backtrace:
  1. base `<fn>`(x)
  2. ggplot2:::print.ggplot(x)
  4. ggplot2:::ggplot_gtable.ggplot_built(data)
  5. layout$setup_panel_guides(plot$guides, plot$layers, plot$mapping)
  6. ggplot2 setup_panel_guides(..., self = self)
  7. base::lapply(...)
  8. ggplot2 FUN(X[[i]], ...)
  9. ggplot2 train_panel_guides(..., self = self)
 10. base::lapply(...)
 11. ggplot2 FUN(X[[i]], ...)
 13. ggplot2:::guide_train.axis(guide, panel_params[[aesthetic]])
 14. scale$get_labels(breaks)
 15. ggplot2 get_labels(..., self = self)
 16. self$scale$get_labels(breaks)
 17. ggplot2 get_labels(..., self = self)
---
Backtrace:
     x
  1. +-base `<fn>`(x)
  2. \-ggplot2:::print.ggplot(x)
  3.   +-ggplot2::ggplot_gtable(data)
  4.   \-ggplot2:::ggplot_gtable.ggplot_built(data)
  5.     \-layout$setup_panel_guides(plot$guides, plot$layers, plot$mapping)
  6.       \-ggplot2 setup_panel_guides(..., self = self)
  7.         \-base::lapply(...)
  8.           \-ggplot2 FUN(X[[i]], ...)
  9.             \-ggplot2 train_panel_guides(..., self = self)
 10.               \-base::lapply(...)
 11.                 \-ggplot2 FUN(X[[i]], ...)
 12.                   +-ggplot2::guide_train(guide, panel_params[[aesthetic]])
 13.                   \-ggplot2:::guide_train.axis(guide, panel_params[[aesthetic]])
 14.                     \-scale$get_labels(breaks)
 15.                       \-ggplot2 get_labels(..., self = self)
 16.                         \-self$scale$get_labels(breaks)
 17.                           \-ggplot2 get_labels(..., self = self)
 18.                             \-cli::cli_abort("{.arg breaks} and {.arg labels} are different lengths")
 19.                               \-rlang::abort(message, ..., call = call, use_cli_format = TRUE)Plot output from version 3.3.6 on CRAN
Created on 2022-05-26 by the reprex package (v2.0.1)
Metadata
Metadata
Assignees
Labels
No labels

