Skip to content

Feature request: coord_polar() argument to transform angle aesthetic. #5059

Closed

Description

@teunbrand

Hi everyone,

I've quite frequently encountered people on stackoverflow having trouble aligning text to plots in polar coordinates.
I think it would be relatively straightforward to propagate the theta aesthetic to text angles, so I was wondering whether it might be considered to give a transform_angle = FALSE/TRUE argument to coord_polar() so that we could transform a plot that looks like this:

library(ggplot2)

df <- data.frame(
  x = 1:5,
  label = c("cat", "dog", "banana", "apple", "coffee")
)

p <- ggplot(df, aes(x, 1, label = label)) +
  scale_x_continuous(limits = c(1, 6)) +
  coord_polar()

p + geom_text()

Into one that looks like this:

p + geom_text(angle = seq(360, 0, length.out = 6)[-6])

Created on 2022-11-24 by the reprex package (v2.0.1)

Perhaps it could even be detected when text has an angle between 90° and 270° to add an extra 180° to improve readability. I'd be willing to take a stab at a PR if this is something that is deemed fitting for ggplot2.

Activity

  1. added
    feature
    on Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coord 🗺️feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions