Created
December 8, 2025 13:14
-
-
Save tukachev/d55b71e2d931beb34560a4ff49090cfe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| library(tidyverse) | |
| # данные | |
| age_groups <- c("до 24 лет", | |
| "25-34 лет", | |
| "35-44 лет", | |
| "45-54 лет", | |
| "55-64 лет", | |
| "от 65 лет") | |
| percentages <- c(12.63, 30.85, 35.77, 13.16, 4.79, 2.79) | |
| df <- tibble(group = factor(age_groups, levels = age_groups), | |
| percent = percentages) | |
| # цвет | |
| colors <- rep("gray75", nrow(df)) | |
| colors[which.max(df$percent)] <- "#00A000" | |
| #график | |
| ggplot(df, aes(x = group, y = percent, fill = group)) + | |
| geom_col(width = 0.7) + | |
| scale_y_continuous( | |
| limits = c(0, 40), | |
| breaks = c(0, 10, 20, 30, 40), | |
| labels = c("0", "10", "20", "30", "40%"), | |
| expand = expansion(mult = c(0, 0.03)) | |
| ) + | |
| scale_fill_manual(values = colors, guide = "none") + | |
| labs( | |
| title = "Будущие соседи: кто будет жить рядом?", | |
| subtitle = "Более трети потенциальных соседей в возрасте 35–44 лет", | |
| x = NULL, | |
| y = NULL | |
| ) + | |
| geom_text( | |
| family = "PT Sans", | |
| aes(label = paste0(percent, "%")), | |
| vjust = -0.6, | |
| size = 4 | |
| ) + | |
| theme_minimal(base_size = 14) + | |
| theme( | |
| axis.text.x = element_text(size = 12, hjust = 0.5), | |
| axis.text.y = element_text(size = 12, colour = "#666666"), | |
| panel.grid.major.y = element_line(colour = "#E0E0E0", linewidth = 0.4), | |
| panel.grid.minor = element_blank(), | |
| panel.grid.major.x = element_blank(), | |
| plot.margin = margin(20, 20, 20, 20), | |
| plot.title.position = "plot", | |
| plot.title = element_text( | |
| family = "PR Sans", | |
| size = 20, | |
| face = "bold", | |
| hjust = 0, | |
| margin = margin(b = 10) | |
| ), | |
| plot.subtitle = element_text( | |
| family = "PT Sans", | |
| color = "#666666", | |
| size = 16, | |
| hjust = 0, | |
| margin = margin(b = 15) | |
| ), | |
| text = element_text(family = "PT Sans", size = 14), | |
| plot.background = element_rect(fill = "white", color = NA), | |
| panel.background = element_rect(fill = "white", color = NA) | |
| ) | |
| ggsave("domclick.png", | |
| width = 7, | |
| height = 6, | |
| dpi = 300) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment