Skip to content

Instantly share code, notes, and snippets.

@eliardocosta
Created June 10, 2021 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliardocosta/9cba5938e56d1ba7d1ce83fb53c1f421 to your computer and use it in GitHub Desktop.
Save eliardocosta/9cba5938e56d1ba7d1ce83fb53c1f421 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(ggplot2)
diamonds %>%
count(cut) %>%
arrange(desc(cut)) %>%
mutate(prop = n/sum(n) ) %>%
mutate(lab.ypos = cumsum(prop) - 0.5*prop) %>%
ggplot(aes(x = "", y = prop, fill = cut)) +
geom_bar(width = 1, stat = "identity", color = "white") +
coord_polar("y", start = pi/2) +
scale_fill_brewer(palette="Blues") +
labs(fill = "Corte") +
geom_text(aes(y = lab.ypos, x=1.65, label = scales::percent(round(prop,3))), color = "black") +
theme_void()
diamonds %>%
ggplot(aes(x = cut)) +
geom_bar(fill = "steelblue", alpha = 0.8, width = 0.8) +
theme_classic(base_size = 16) +
labs(x = "Classificação do diamante segundo corte", y="Frequência")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment