Skip to content

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

Closed
@acebulsk

Description

@acebulsk

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions