Labels too wide for alluvial plot
hrdawson opened this issue · 0 comments
hrdawson commented
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](https://private-user-images.githubusercontent.com/36278527/328351013-ee3bfe08-353a-4d7a-b270-379563e8287a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzI3Mzc2MTAsIm5iZiI6MTczMjczNzMxMCwicGF0aCI6Ii8zNjI3ODUyNy8zMjgzNTEwMTMtZWUzYmZlMDgtMzUzYS00ZDdhLWIyNzAtMzc5NTYzZTgyODdhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDExMjclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMTI3VDE5NTUxMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ0ZGNlMTNmZTQ5MDBjZjNiN2VlM2M5NWE5YTNlNjc2NjYxYTM3ODc3YTRkZWU4OTcwMDAwZmY2YjYzMzU5MjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.1DM2jXxpYWr014jp_mCi9WEM17JqtfkLMqp_EwE0dTQ)
Thanks for the great package!