Skip to content
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

Could the x and y axis position move when coord_radial is used? #5735

Closed
davidhodge931 opened this issue Mar 1, 2024 · 3 comments · Fixed by #5748
Closed

Could the x and y axis position move when coord_radial is used? #5735

davidhodge931 opened this issue Mar 1, 2024 · 3 comments · Fixed by #5748

Comments

@davidhodge931
Copy link

davidhodge931 commented Mar 1, 2024

Currently only the y axis title moves

library(tidyverse)

mpg |> 
  ggplot() +
  geom_boxplot(aes(x = class, y = displ)) +
  coord_radial() +
  scale_y_continuous(position = "right")

Created on 2024-03-02 with reprex v2.1.0

@teunbrand
Copy link
Collaborator

It is a little bit more complicated than just moving the axis.
In particular, if you have start/end settings that don't include a vertical angle, the axis is placed horizontally.
So position = "right", or position = "left" for that matter, cannot apply correctly.

library(ggplot2)

mpg |> 
  ggplot() +
  geom_boxplot(aes(x = class, y = displ)) +
  coord_radial(start = 0.25 * pi, end = 0.75 * pi, r_axis_inside = FALSE)

Also if you have a bottom-half circle, the position would be on the right visually even though it is the primary axis.

mpg |>
  ggplot() +
  geom_boxplot(aes(x = class, y = displ)) +
  coord_radial(start = 0.5 * pi, end = 1.5 * pi)

If you must have a guide on the right, you can use the r.sec name in guides().

mpg |> 
  ggplot() +
  geom_boxplot(aes(x = class, y = displ)) +
  coord_radial() +
  guides(r = "none", r.sec = "axis")

Created on 2024-03-04 with reprex v2.1.0

@davidhodge931
Copy link
Author

It works for coord_polar, so it'd be cool if could work for coord_radial. But I see it's a bit more complicated than I'd thought.

An idea is to just switch by 180 degrees where-ever the axis was, if someone uses position = "right" or "top"? That would make sense when it was a full or half pie, which would cover off most situations.

Feel free to close

@teunbrand
Copy link
Collaborator

There is something to say for this from a consistency standpoint. However, I don't think it makes sense to use a flipping mechanism for the theta axis: that would only work if inner.radius allows enough space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants