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

Labels too wide for alluvial plot #47

Open
hrdawson opened this issue May 7, 2024 · 0 comments
Open

Labels too wide for alluvial plot #47

hrdawson opened this issue May 7, 2024 · 0 comments

Comments

@hrdawson
Copy link

hrdawson commented May 7, 2024

I'd like to use the alluvial plot for some data with long variables. However, geom_alluvial_text seems to have a set width that doesn't change even when the label needs to be much wider. It would also be helpful if the vertical dimension could resize so that labels have a margin to prevent overlap, and if the labels could justify to the right/left so they don't bleed onto the ribbons. Using starwars as an example:

library(tidyverse)

df <- starwars |>
  make_long(species, homeworld)

ggplot(df, aes(x = x, next_x = next_x, node = node, next_node = next_node, fill = factor(node), label = node)) +
  geom_alluvial(flow.alpha = .6) +
  geom_alluvial_text(size = 3, color = "white") +
  scale_fill_viridis_d(drop = FALSE) +
  theme_alluvial(base_size = 18) +
  labs(x = NULL) +
  theme(legend.position = "none",
        plot.title = element_text(hjust = .5))
Screenshot 2024-05-06 at 17 33 49

Thanks for the great package!

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