Created
January 20, 2023 10:27
-
-
Save tukachev/f9b1f4d563c2c79662ea6ed220777abd to your computer and use it in GitHub Desktop.
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
pacman::p_load(ggbump, tidyverse, cowplot, wesanderson, ggrepel) | |
df <- tibble( | |
region = c(rep("Магнитогорск", 5), | |
c(rep("Челябинск", 5)), | |
c(rep("Нижний Тагил", 5))), | |
year = c( | |
2017, | |
2018, | |
2019, | |
2020, | |
2021, | |
2017, | |
2018, | |
2019, | |
2020, | |
2021, | |
2017, | |
2018, | |
2019, | |
2020, | |
2021 | |
), | |
level = c( | |
"ОВ", | |
"В", | |
"В", | |
"П", | |
"П", | |
"В", | |
"П", | |
"П", | |
"П", | |
"В", | |
"В", | |
"Н", | |
"П", | |
"В", | |
"В" | |
) | |
) | |
df <- df %>% mutate( | |
level_desc = factor( | |
level, | |
levels = c("ОВ", | |
"В", | |
"П", | |
"Н"), | |
labels = c("Очень высокий", "Высокий", "Повышенный", "Низкий") | |
), | |
rank = 5 - as.numeric(level_desc) | |
) | |
levels_desc <- c("Низкий", | |
"Повышенный", | |
"Высокий", | |
"Очень\nвысокий") | |
ggplot(df, aes(year, rank, color = region)) + | |
geom_text( | |
aes(2021, 3, label = "Челябинск"), | |
color = "#40B0A6", | |
hjust = "inward", | |
nudge_y = .4, | |
size = 6 | |
) + | |
geom_text( | |
aes(2021, 2, label = "Магнитогорск"), | |
color = "#006CD1", | |
hjust = "inward", | |
nudge_y = -.25, | |
size = 6 | |
) + | |
geom_text( | |
aes(2021, 3, label = "Нижний Тагил"), | |
color = "#5D3A9B", | |
hjust = "inward", | |
nudge_y = .2, | |
size = 6 | |
) + | |
geom_bump(size = 2, smooth = 7) + | |
geom_point(size = 7) + | |
scale_y_continuous(breaks = c(1:4), labels = levels_desc) + | |
theme_minimal_grid(font_size = 18, line_size = 0) + | |
labs( | |
title = "Динамика уровня загрязнения атмосферного\nвоздуха в 2017 – 2021", | |
subtitle = "Магнитогорск, Челябинск и Нижний Тагил включены в Федеральный\nпроект «Чистый воздух» Национального проекта «Экология»\n", | |
caption = "\nИсточник данных: Росгидромет, 2022\nОбзор состояния и загрязнения окружающей среды в Российской Федерации за 2021 год\nURL: https://www.meteorf.gov.ru/product/infomaterials/90/", | |
y = NULL, | |
x = NULL | |
) + | |
scale_color_manual(values = c("#006CD1", "#40B0A6", "#5D3A9B")) + | |
# scale_color_manual(values = c("#8dd3c7", "#bebada", "#80b1d3")) + | |
theme( | |
legend.position = "none", | |
panel.grid.major = element_blank(), | |
text = element_text(size = 18, family = "OpenSans"), | |
axis.text = element_text(color = "gray30", size = 15), | |
plot.caption = element_text( | |
color = "gray30", | |
hjust = 0, | |
size = 11 | |
), | |
title = element_text(size = 18), | |
plot.subtitle = element_text(color = "gray30", size = 15), | |
plot.title = element_text(hjust = 0), | |
plot.title.position = "plot", | |
plot.caption.position = "plot", | |
plot.margin = margin(25, 25, 10, 25) | |
) | |
ggsave( | |
"city_levels.png", | |
bg = "white", | |
width = 6, | |
height = 6, | |
dpi = 300, | |
scale = 1.2 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment