Skip to content

Instantly share code, notes, and snippets.

@eduardofox2
Created January 21, 2020 16:52
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 eduardofox2/f9331d0a76cb1ea8dd261cce130bc47f to your computer and use it in GitHub Desktop.
Save eduardofox2/f9331d0a76cb1ea8dd261cce130bc47f to your computer and use it in GitHub Desktop.
Image prepared for a friend, concerning 3 university scores over the years [In Portuguese]
library(ggplot2)
library(magick)
library(reshape2)
#Imagens de icons obtidas a partir da Wikipedia, creditos das imagens abaixo
#Por Massachusetts Institute of Technology - http://www.mit.edu/, vectorized by Mysid, Domínio público, https://commons.wikimedia.org/w/index.php?curid=9464159
#Por José Wasth Rodrigues - http://www.scs.usp.br/identidadevisual/?page_id=10, Domínio público, https://commons.wikimedia.org/w/index.php?curid=60453569
#Por B1mbo (talk) Este desenho vetorial foi criado com Inkscape, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=8400886#Usando ícones de bandeiras baixadas no meu computador (Ajustar locale para o de quem usar este script)
MIT_icon<-image_read('C:\\Users\\Eduardo\\Downloads\\1920px-MIT_logo.svg.png')
USP_icon<-image_read('C:\\Users\\Eduardo\\Downloads\\USP.svg.png')
UChile_icon<-image_read('C:\\Users\\Eduardo\\Downloads\\PUC_Chile.png.png')
#these extensions are somewhat glitchy on my windows interface
Imp_top10<-
data.frame(
anos =seq(2007, 2018),
USP =c(NA, NA, 5.3, 5.4, 5.3, 5.4, 5.2, 5.4, 5.9, 6, 6.2, NA),
MIT =c(NA, NA, 23.9, 24.5, 24.6, 24.7, 24.9, 24.9, 24.8, 25, 24.6, NA),
Chile=c(NA, NA, 7.1, 7, 7.6, 7.4, 7.4, 7.5, 8.2, 8.2, 7.9, NA)
)
Figura<-
ggplot(Imp_top10)+
geom_point(aes(y=USP, x=anos), colour="#009C3B", size = 3)+
geom_smooth(aes(y=USP, x=anos), method = "loess", se = FALSE, size = 1, span = 1, colour="#009C3B", linetype = "dotted") +
geom_point(aes(y=MIT, x=anos), colour="#ff0000", size = 3)+
geom_smooth(aes(y=MIT, x=anos), method = "loess", se = FALSE, size = 1, span = 1, colour="#ff0000", linetype = "dotted") +
geom_point(aes(y=Chile, x=anos), colour="blue", size = 3)+
geom_smooth(aes(y=Chile, x=anos), method = "loess", se = FALSE, size = 1, span = 1, colour="blue", linetype = "dotted") +
scale_x_continuous(limits=c(2007.5,2018), breaks=seq(2009,2017,1), expand = c(0, 0.005))+
scale_y_continuous(limits=c(-1.5,27), breaks=seq(0,27,5))+
annotate("text", x = 2009, y = 25, label = "MIT")+
annotate("text", x = 2009.2, y = 9, label = "PUC Chile")+
annotate("text", x = 2009, y = 3.5, label = "USP")+
labs(title = "Impacto em %-top10%", x="Anos", y=NULL)+
theme_classic()
Figura.final<-ggdraw(Figura) +
draw_image(MIT_icon, scale=0.08, x=-0.4, y=0.31)+
draw_image(UChile_icon, scale=0.12, x=-0.4, y=-0.1)+
draw_image(USP_icon, scale=0.13, x=-0.4, y=-0.26)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment