Hi everyone - I’m trying to plot a pie chart, but I keep getting the same error when I add the ggrepel labels. I’ve searched a lot and asked classmates, but I still can’t fix it. Could someone help?
ggplot(dados_pizza, aes(ymax = ymax, ymin = ymin, xmax = 1, xmin = 0, fill = discriminacao)) +
geom_rect(color = "grey20") +
coord_polar(theta = "y") +
labs(
title = paste("Receitas Municipais", " - ", ano_escolhido),
fill = "Conta"
) +
scale_fill_manual(
values = paleta_gradual(n_distinct(dados_pizza$discriminacao)),
labels = vetor_legenda_uniao
) +
geom_text(
data = subset(dados_pizza, prop >= 0.05),
aes(x = 0.5, y = ymid, label = prop_label),
inherit.aes = FALSE,
color = "white", size = 3
) +
#this is where the error happens
ggrepel::geom_text_repel(
** data = subset(dados_pizza, 0.01 < prop & prop < 0.05),**
** aes(x = 1, y = ymid*0.5, label = prop_label),**
** inherit.aes = FALSE,**
** size = 3,**
** color = "black",**
** nudge_x = 0.5,
** box.padding = 0.2,**
** point.padding = 0.2,**
** max.overlaps = 5**
** )** +
theme_void()
Error:
Error in grid.Call(C_convert, x, as.integer(whatfrom), as.integer(whatto), : **
** Viewport has zero dimension(s)

