Skip to content

Instantly share code, notes, and snippets.

@JuveCampos
Last active January 31, 2020 16:49
Show Gist options
  • Save JuveCampos/3eae754b380fd5646a33a61ab4bc3a5d to your computer and use it in GitHub Desktop.
Save JuveCampos/3eae754b380fd5646a33a61ab4bc3a5d to your computer and use it in GitHub Desktop.
### Grafica ----
(plt <- ggplot(pop, aes(x = `Grupos quinquenales de edad`,
y = `Poblacion por Sexo`,
fill = Sexo)) +
# Seccion de HOMBRES
geom_col(data = subset(pop, Sexo == "Hombres") %>%
# Convertimos los datos de los Hombres en negativos
mutate(`Poblacion por Sexo` = -`Poblacion por Sexo`),
width = 0.5, fill = "blue") +
# Seccion de MUJERES
geom_col(data = subset(pop, Sexo == "Mujeres"),
width = 0.5, fill = "pink") +
# Cambio de ejes de coordenadas
coord_flip() +
scale_y_continuous(
breaks = c(seq(-100000, -20000, by = 20000),
seq(0, 100000, by = 20000)),
labels = c(seq(-100000, -20000, by = 20000) * -1,
seq(0, 100000, by = 20000))) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment