plotly/plotly.R

geom_GeomLabelRepel() has yet to be implemented in plotly

foma4tune opened this issue · 2 comments

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)

Duplicate of #2408

thanks for pointing out it's a duplicate #2408 . Resolving the issue will be greatly appreciated.