5
I would like to know if there is a possibility to change the orientation of the filling of the colors of the following chart
What I want is for the colors to be filled from the outside in. Does anyone have any idea?
dat <- structure(list(
Category = structure(1:15,
.Label = c("ID1", "ID2", "ID3", "ID4", "ID5", "ID6", "ID7", "ID8", "ID9", "ID10",
"ID11", "ID12", "ID13", "ID14", "ID15"), class = "factor"),
Percentage = c(0.8, 0.32, 0.15, 0.6, 0.4, 0.5, 0.3, 0.7, 1, 0.8, 0.3, 0.9, 0, 0.2, 0.46)),
.Names = c("Category", "Percentage"), row.names = c(NA, 15L), class = "data.frame")
ggplot(data = dat) +
geom_col(aes(x = Category, fill = Category, y = Percentage), width = 1) +
geom_hline(yintercept = 1, color = "darkgrey", size = 1) + #ponto de partida
geom_segment(aes(x = 1.5, xend = 4.5, y = .75, yend = .75), color = "darkgrey", size = 1) +#2017
geom_segment(aes(x = 5.5, xend = 15.5, y = .75, yend = .75), color = "darkgrey", size = 1) +#2017
geom_segment(aes(x = 1.5, xend = 15.5, y = .5, yend = .5), color = "darkgrey", size = 1) +#2018
geom_segment(aes(x = .5, xend = 4.5, y = .25, yend = .25), color = "darkgrey", size = 1) +#2019
geom_segment(aes(x = 5.5, xend = 15.5, y = .25, yend = .25), color = "darkgrey", size = 1) +#2019
geom_vline(xintercept = seq(.5, 15.5, by = 1), color = "darkgrey", size = 1) +
coord_polar() +
theme_minimal() +
labs(x = NULL, y = NULL) +
theme(axis.text.y = element_blank(),
legend.position = "none",
panel.grid = element_blank())
I was trying to solve this problem in a completely different way. I understood that the excerpt "the colors are filled from outside to inside" meant that each circular sector should be filled in an orange to pink gradient. Like, all circular sectors would be orange for
Percentage
0,1; green toPercentage
0.3 and so on, up to pink forPercentage
1. I was completely wrong (and no, I couldn’t do the chart I’m describing).– Marcus Nunes
I spent a long time thinking about how best to describe my problem, and ended up deciding what I wrote. Maybe this chart of yours can be done with several columns of
Percentage
with specific values for each sector. Then there would be ageom_col
for each of these, with the optionfill = cor
, starting from the outside.– Rafael Cunha