Created
February 28, 2017 13:10
-
-
Save ccamara/dc6455f6c7a6846e3b70fba72bd75ce4 to your computer and use it in GitHub Desktop.
Annotation in #R #ggplot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: http://sharpsightlabs.com/blog/simple-annotate-plot-ggplot2/ | |
ggplot(df, aes(x = Año, y = Población, group = 1)) + | |
geom_line(colour = "red", size = 1.5) + | |
geom_point(colour = "red", size = 4, shape = 21, fill = "white") + | |
geom_text(aes(label = Año), size = 3, hjust = 0.5, vjust = 3, position = "stack") + | |
scale_y_continuous(labels = function(x) format(x, big.mark = ".", scientific = FALSE)) + | |
ggtitle("Evolución de población en Detroit") + | |
labs(x = "Año", y = "Población") + | |
geom_vline(xintercept = 1973, linetype = "dashed") + | |
annotate("text", label = "Crisis petróleo", x = 1975, y = 75000, color = "black") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment