Mestrado 2019.1 - FPCC2 - @Jayne Morais
climas = read_csv(here::here("data/clima_cg_jp-semanal.csv"),
col_types = "cTdddddd")
glimpse(climas)
## Observations: 2,748
## Variables: 8
## $ cidade <chr> "Campina Grande", "Campina Grande", "Campina Grande", "Ca…
## $ semana <dttm> 1992-12-27, 1993-01-03, 1993-01-10, 1993-01-31, 1993-02-…
## $ tmedia <dbl> 26.13333, 26.11905, 25.76667, 25.74000, 26.31429, 26.2857…
## $ tmax <dbl> 30.4, 32.4, 32.2, 32.0, 32.7, 32.7, 32.3, 32.3, 32.1, 31.…
## $ tmin <dbl> 20.7, 19.3, 19.7, 19.9, 19.6, 20.0, 20.4, 21.2, 19.0, 19.…
## $ chuva <dbl> 0.0, 0.0, 0.0, 0.4, 0.3, 0.0, 4.9, 0.0, 0.0, 6.1, 0.4, 1.…
## $ mes <dbl> 12, 1, 1, 1, 2, 2, 2, 2, 10, 11, 11, 11, 11, 12, 12, 12, …
## $ ano <dbl> 1992, 1993, 1993, 1993, 1993, 1993, 1993, 1993, 1993, 199…
Resolução da atividade de geração de visualização 26/04
climas %>%
group_by(cidade, ano, mes) %>%
filter(ano == 2018) %>%
summarise(media_chuva = mean(chuva)) %>%
ggplot(mapping = aes(x = mes, y = media_chuva, color = cidade)) +
geom_line() +
geom_point() +
geom_smooth(aes(x = mes, y = media_chuva), method = lm, se = FALSE) +
scale_x_continuous(breaks = seq(from = 0, to = 2018, by = 1)) +
scale_y_continuous(breaks = seq(from = 0, to = 300, by = 5)) +
theme(legend.position = "bottom",
legend.box.just = "center",
legend.margin = margin(6, 6, 6, 6),
axis.text.x = element_text(color = "grey20", size = 8, angle = 0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "grey20", size = 8, angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x = element_text(color = "grey20", size = 8, angle = 0, hjust = .5, vjust = 0, face = "plain"),
axis.title.y = element_text(color = "grey20", size = 8, angle = 90, hjust = .5, vjust = .5, face = "plain")) +
theme(plot.title = element_text(size = 10, face = "bold")) +
labs(
title = "Média de chuva mensal em 2018",
#subtitle = "João Pessoa X Campina grande",
y = "Média de Chuva (ml)",
x = "Mês (2018)"
)

ggsave("relacao_chuva.pdf", width = 3.5 , height = 4)
climas %>%
group_by(cidade, ano) %>%
filter(ano >= 2008, ano <= 2018) %>%
summarise(media_temperatura = mean(tmedia)) %>%
ggplot(mapping = aes(x = ano, y = media_temperatura, color = cidade)) +
#geom_line() +
geom_point() +
xlab("Ano") +
ylab("Média de Temperatura (ºC)") +
scale_x_continuous(breaks = seq(from = 1, to = 2018, by = 1)) +
scale_y_continuous(breaks = seq(from = 1, to = 30, by = 0.5)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
geom_smooth(aes(x = ano, y = media_temperatura), method = lm, se = FALSE) +
theme(legend.position = "bottom",
legend.box.just = "center",
legend.margin = margin(6, 6, 6, 6),
axis.text.x = element_text(color = "grey20", size = 8, angle = 90, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "grey20", size = 8, angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x = element_text(color = "grey20", size = 8, angle = 0, hjust = .5, vjust = 0, face = "plain"),
axis.title.y = element_text(color = "grey20", size = 8, angle = 90, hjust = .5, vjust = .5, face = "plain")) +
theme(plot.title = element_text(size = 10, face = "bold")) +
labs(
title = "Média de temperatura anual",
y = "Média de Temperatura (ºC)",
x = "Ano"
)

ggsave("relacao_temperatura.pdf", width = 3.5 , height = 4)