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

Feature request / offer: element_text_repel() #248

Open
teunbrand opened this issue Jan 13, 2024 · 0 comments
Open

Feature request / offer: element_text_repel() #248

teunbrand opened this issue Jan 13, 2024 · 0 comments

Comments

@teunbrand
Copy link

Hi Kamil and others,

I have been musing for a while that it'd be great if we could have axis text repelled.
This could be great for e.g. heatmaps that highlight only some rows or columns.
For example, in the plot below there is ample spacing for 'Texas', 'New York' and 'California' but the states starting with 'M' are a little bit cramped.

library(ggplot2)

df <- reshape2::melt(as.matrix(USArrests))

ggplot(df, aes(Var2, Var1, fill = value)) +
  geom_tile() +
  scale_y_discrete(
    breaks = c("Missouri", "Mississippi", "Minnesota", "Michigan", 
               "Massachusetts", "New York", "California", "Texas")
  )

Created on 2024-01-13 with reprex v2.0.2

I'm reasonably confident that it should be possible to capture that axis repelling into an element_text_repel() theme setting that you can feed to the axis text elements.
If this is something you think might be a good fit for {ggrepel}, I'll be happy to prepare a PR and discuss further.
Thanks for reading!

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

No branches or pull requests

1 participant