Last active
January 31, 2018 02:02
-
-
Save diegovalle/f9f7c7b2c4eb603d7a869efe3b50854b to your computer and use it in GitHub Desktop.
Hourly January temperatures for all reporting sensors for 2016-2018
This file contains 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
#based on https://cran.r-project.org/web/packages/ggjoy/vignettes/gallery.html | |
library(viridis) | |
library(ggridges) | |
library(aire.zmvm) | |
library(lubridate) | |
library(ggplot2) | |
library(dplyr) | |
library(tidyr) | |
library(stringr) | |
library(lubridate) | |
temp <- data.frame() | |
for (year in 2005:2018) { | |
df2 <- get_station_single_month("TMP", year, 1) | |
temp <- rbind(temp, df2) | |
} | |
temp$month <- months(temp$date) | |
temp$month <- factor(temp$month, levels = rev(unique(temp$month)) ) | |
temp$month <- str_c(temp$month, " - ", year(temp$date)) | |
temp$year <- year(temp$date) | |
# remove stations that always report 0 | |
temp <- temp %>% | |
group_by(year, station_code) %>% | |
filter(!sum(value, na.rm = TRUE) == 0) | |
ggplot(temp, aes(x = value, y = month, fill = ..x..)) + | |
geom_density_ridges_gradient(scale = 3, rel_min_height = 0.01, gradient_lwd = 1.) + | |
scale_x_continuous(expand = c(0.01, 0)) + | |
scale_y_discrete(expand = c(0.01, 0)) + | |
scale_fill_viridis(name = "Temp. [C]", option = "C") + | |
labs(title = 'January Temperatures in Mexico city', | |
subtitle = 'Hourly January temperatures for all reporting sensors 2005-2018\nSource: SEDEMA') + | |
theme_ridges(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment