#Source: https://t.me/rstudioprogr

library(ggplot2)
library(ggrepel)
library(hrbrthemes)
library(viridis)
library(viridisLite)

countries <- c("US", "China", "Russia", "India", "Germany", "Canada", "Japan", "UK")
key_rate <- c(4.33, 3.1, 21, 6.25, 3.65, 3, 0.5, 4.5)
PMI <- c(51.6, 50.2, 53.1, 57.1, 46.1, 47.1, 48.9, 46.4)
gdp_per_capita <- c(87.9, 28.1, 15.1, 11.9, 57.9, 62.7, 35.6, 58.1)
continents <- c("North America",   # US
                "Asia",            # China
                "Europe",         # Russia
                "Asia",           # India
                "Europe",         # Germany
                "North America",  # Canada
                "Asia",           # Japan
                "Europe")         # UK

data <- data.frame(countries, key_rate, PMI, gdp_per_capita, continents)

# Строим график
ggplot(data, aes(x = key_rate, y = PMI)) + 
  geom_point(alpha = 0.3, aes(size = gdp_per_capita, color = continents)) + 
  theme_ipsum(axis_title_size = 12) +
  labs(x = "Ключевая ставка", y = "PMI") +
  labs(size = "ВВП на душу", color = "Континент") +
  geom_smooth(method = "lm", se = FALSE) + 
  geom_label_repel(aes(label = countries), 
                   max.overlaps = 70,
                   min.segment.length = 0,
                   box.padding = 0.5, 
                   point.padding = 0.1,
                   segment.color = 'grey50') + scale_color_viridis_d()