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

geom_GeomLabelRepel() has yet to be implemented in plotly #2423

Open
foma4tune opened this issue Feb 7, 2025 · 0 comments
Open

geom_GeomLabelRepel() has yet to be implemented in plotly #2423

foma4tune opened this issue Feb 7, 2025 · 0 comments

Comments

@foma4tune
Copy link

pie chart

df_2 <- data.frame(value = c(15, 25, 32, 28),
group = paste0("G", 1:4))

Get the positions

df2 <- df_2 %>%
mutate(csum = rev(cumsum(rev(value))),
pos = value/2 + lead(csum, 1),
pos = if_else(is.na(pos), value/2, pos))

label_piechart <- ggplot(df, aes(x = "" , y = value, fill = fct_inorder(group))) +
geom_col(width = 1, color = 1) +
coord_polar(theta = "y") +
scale_fill_brewer(palette = "Pastel1") +
geom_label_repel(data = df2,
aes(y = pos, label = paste0(value, "%")),
size = 4.5, nudge_x = 1, show.legend = FALSE) +
guides(fill = guide_legend(title = "Group")) +
theme_void()

ggplotly(label_piechart)

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