Este ?? um simple plot para mostrar ciclo de vida de um SCM. O arquivo ???scm_scv.csv??? pode ser baixado em https://sites.google.com/site/rgisairpollution/materiales/scm_csv.csv
Para rodar o script a seguir ?? necesario ter a libreria ggplot2 instalada. Agora, para instalar R ?? preciso a agregar o seguente a nosso sources.list:
sudo gedit /etc/apt/sources.list
deb http://www.vps.fmvz.usp.br/CRAN/bin/linux/ubuntu utopic/
Logo ?? preciso importar a chave, colando e copiando na terminal:
sudo apt-key adv ???keyserver keyserver.ubuntu.com ???recv-keys E084DAB9
sudo apt-get update
sudo apt-get install r-base
sudo gedit /etc/apt/sources.list
deb http://www.vps.fmvz.usp.br/CRAN/bin/linux/debian wheezy-cran3/
Logo ?? preciso importar a chave, colando e copiando na terminal:
sudo apt-key adv ???keyserver keys.gnupg.net ???recv-key 381BA480
sudo apt-get update
sudo apt-get install r-base
#install.packages("ggplot2")
library(ggplot2)
setwd("/home/sergio/Downloads")
scm <- read.csv("/home/sergio/Downloads/scm_csv.csv",h=T)
names(scm)
## [1] "hora" "pixels" "area_km2" "time"
scm
## hora pixels area_km2 time
## 1 900 267 4272 09:00
## 2 930 402 6432 09:30
## 3 1000 473 7568 10:00
## 4 1100 788 12608 11:00
## 5 1130 884 14144 11:30
## 6 1200 879 14064 12:00
## 7 1300 968 15488 13:00
## 8 1330 998 15968 13:30
## 9 1400 935 14960 14:00
## 10 1500 1063 17008 15:00
## 11 1530 1074 17184 15:30
## 12 1600 1023 16368 16:00
## 13 1700 949 15184 17:00
## 14 1730 866 13856 17:30
## 15 1800 797 12752 18:00
#Com hora n??o ordenada
ggplot(scm, aes(x=hora, y=area_km2)) + geom_line(stat="identity",size=2)+
ggtitle("No Title!")+
theme(plot.title = element_text(lineheight=1, face="bold", size=20),
axis.text.x=element_text(size=15, face="bold"),
axis.text.y=element_text(size=15, face="bold"))+ ylab("Area Km??")+ xlab("Hora")
#Com geom_bar, x=hora
ggplot(scm, aes(x=hora, y=area_km2)) + geom_bar(stat="identity")+
ggtitle("No Title!")+
theme(plot.title = element_text(lineheight=1, face="bold", size=20),
axis.text.x=element_text(size=15, face="bold"),
axis.text.y=element_text(size=15, face="bold"))+ ylab("Area Km??")+ xlab("Hora")
#Com geom_bar, x=time
ggplot(scm, aes(x=time, y=area_km2)) + geom_bar(stat="identity")+
ggtitle("No Title!")+
theme(plot.title = element_text(lineheight=1, face="bold", size=20),
axis.text.x=element_text(size=10, face="bold"),
axis.text.y=element_text(size=10, face="bold"))+ ylab("Area Km??")+ xlab("Hora")
#Com Smooth
ggplot(scm, aes(x=hora, y=area_km2)) + stat_smooth()+
ggtitle("No Title!")+
theme(plot.title = element_text(lineheight=1, face="bold", size=20),
axis.text.x=element_text(size=15, face="bold"),
axis.text.y=element_text(size=15, face="bold"))+ ylab("Area Km??")+ xlab("Hora")
## geom_smooth: method="auto" and size of largest group is <1000, so using loess. Use 'method = x' to change the smoothing method.
#Com Smooth e geom_point
ggplot(scm, aes(x=hora, y=area_km2)) + stat_smooth()+ geom_point(size=3)+
ggtitle("No Title!")+
theme(plot.title = element_text(lineheight=1, face="bold", size=20),
axis.text.x=element_text(size=15, face="bold"),
axis.text.y=element_text(size=15, face="bold"))+ ylab("Area Km??")+ xlab("Hora")
## geom_smooth: method="auto" and size of largest group is <1000, so using loess. Use 'method = x' to change the smoothing method.