-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Custom inside-axis position for coord_radial()
#5908
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
Conversation
This is really nice! Am I correct that the radius axis angle provided to See code below: set.seed(42)
df <- data.frame(x = runif(100, max = 360), y = rnorm(100))
p <- ggplot(df, aes(x, y)) +
geom_point() +
scale_x_continuous(limits = c(0, 360), breaks = seq(0, 360, by = 90)) +
theme(axis.line = element_line())
p + coord_radial(theta = "x",
direction = -1,
start = -90 * pi / 180,
clip = "off",
r_axis_inside = 135,
inner.radius = 0.075,
expand = FALSE) |
Thanks for raising these points!
The
Yeah that shouldn't happen, I'll try to figure out what is going wrong here. |
Now correctly places axis at 135 degrees: set.seed(42)
devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
df <- data.frame(x = runif(100, max = 360), y = rnorm(100))
p <- ggplot(df, aes(x, y)) +
geom_point() +
scale_x_continuous(limits = c(0, 360), breaks = seq(0, 360, by = 90)) +
theme(axis.line = element_line())
p + coord_radial(theta = "x",
direction = -1,
start = -90 * pi / 180,
clip = "off",
r.axis.inside = 135,
inner.radius = 0.075,
expand = FALSE) Created on 2024-06-27 with reprex v2.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR aims to fix #5805.
Briefly, you can now use numeric values for
coord_radial(r.axis.inside)
that will place the radius axis at some specified position of the theta axis.I think it is probably best illustrated how it works.
Let's make plot with clock-positions.
This is how one would set the position:
If for some reason you have secondary axes, you can set a vector to control primary and secondary separately.
Out of bounds axes get squished to the nearest limit.
Created on 2024-05-24 with reprex v2.1.0