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

Specify position of r axis for coord_radial when r_axis_inside = T #5805

Open
acebulsk opened this issue Mar 25, 2024 · 2 comments · May be fixed by #5908
Open

Specify position of r axis for coord_radial when r_axis_inside = T #5805

acebulsk opened this issue Mar 25, 2024 · 2 comments · May be fixed by #5908

Comments

@acebulsk
Copy link

When using coord_radial we can move the r axis (aka y axis) inside using r_axis_inside = T. However, when r_axis_inside = T the position defaults to 0 degrees when plotting a full circle and this is confusing the r axis extends into the first value of the theta axis.

I would like to be able to control the position/angle of the r axis when it is inside the plot. For example below I would like to have the r axis at 45 degrees so it is not to be confused with the theta axis.

library(ggplot2)

# Generate data for each combination of circle (360 deg) and radius (0 to 90)
data <- expand.grid(
  angle = seq(0, 359, by = 1),
  radius = seq(0, 90, by = 1),
  value = 0.5
)

# Create the circular plot
ggplot(data, aes(x = angle, y = radius)) +
  geom_tile(alpha = 0.2) +
  coord_radial(
    r_axis_inside = T,
    expand = F
  ) +
  scale_x_continuous(breaks = seq(0, 270, 90)) +
  labs(title = "Circular Plot",
       x = "Angle (degrees)",
       y = "Radius")

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

Here is roughly what I am after:

Screenshot from 2024-03-25 17-27-57

@acebulsk acebulsk changed the title Specify angle of coord_radial r_axis Specify position of r axis for coord_radial when r_axis_inside = T Mar 25, 2024
@teunbrand
Copy link
Collaborator

I can understand why this is useful, but by extension we could also ask why we don't allow e.g. coord_cartesian() to place axes inside the panel at specified positions.

@BenVolpe94
Copy link

Also looking for this feature! Being able to place the r-axis inside gives a much better view on the scale, but sometimes it overlaps with your data (see example below). If I was able to customize the angle it would be much easier to prevent overlapping
image

@teunbrand teunbrand linked a pull request May 24, 2024 that will close this issue
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.

3 participants