-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when setting breaks in coord_radial()
#6271
Comments
While I agree that it shouldn't throw an error here, I'm having a hard time to grok the intention of this code. Even in Cartesian coordinates, the axis will not display labels. |
Maybe something like this? ggplot(data, aes(as.factor(Var1), Var2)) +
geom_tile(aes(fill = value)) +
scale_fill_viridis_c() +
scale_x_discrete(breaks = 1:2) It seems that |
Discrete position scales generally just keep track of the range of continuous data but don't base their categorical limits or breaks on them. The scale cannot find any discrete values, so it begets empty limits, making the |
Somewhat simplified reprex, note that also using empty breaks in the radial axis causes troubles. devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
p <- ggplot(mtcars, aes(mpg, disp)) +
geom_point() +
coord_radial()
p + scale_x_continuous(breaks = character())
#> Error in switch(params$position, top = , right = , theta.sec = -Inf, Inf): EXPR must be a length 1 vector
p + scale_y_continuous(breaks = character())
#> Error in `setup_params()` at ggplot2/R/ggproto.R:188:17:
#> ! `params$position` must be one of "top", "right", "bottom", or "left",
#> not "theta". Created on 2025-01-07 with reprex v2.1.1 |
Thanks for the PR! I’ve tested it, and it works well with this example. Another associated warning message with this example: Warning message:
In groups$key$position : partial match of 'position' to 'positions' This appears to correspond to the following line in the code: Line 544 in efc53cc
|
Thanks, nice catch! |
Created on 2025-01-07 with reprex v2.1.0
I have using the development version of ggplot2.
Session info
The text was updated successfully, but these errors were encountered: