library(ggplot2) library(readr) library(tidyr) # pivot_longer library(ggbreak) # data break point library(scales) # custom trans data <- read_csv("1.csv", col_types = cols( Lastmod = col_date(format = "%Y-%m-%d"), .default = col_integer() # cool import )) # use custom trans to multiply DP 50- to 5x # as DP 2000+ occpies too much space in y axis custom_trans <- trans_new( name = "custom", transform = function(x) ifelse(x < 50, x * 5, x), # if 50-, 5x # "Retired" starts at 400, so we are safe here inverse = function(x) ifelse(x < 250, x / 5, x) # if 250-, 1/5 ) # simplify data to avoid redundant lines data_long <- data %>% pivot_longer(cols = -Lastmod, names_to = "Tag", values_to = "Count") p <- ggplot(data_long, aes(x = Lastmod, y = Count, color = Tag)) + geom_line(alpha = 0.8) + geom_point() + scale_color_manual(values = c( "Playing" = "#2f933a", "Backlogs" = "#2b7ab9", "Replays" = "#439de3", "Stalled" = "#1b7168", "Completed" = "#934b93", "Retired" = "#cb3a3b" )) + # HLTB style scale_y_continuous(trans = custom_trans) + # apply custom trans scale_y_break(c(40, 380)) + # skip gap in y axis scale_y_break(c(700, 2500)) + labs(title = "HLTB Trend 2024", x = "Date", y = "Count", color = "Tag") + theme_minimal() + theme(axis.text.x = element_text(angle = 45, hjust = 1)) ggsave("hltb-trend-2024.png", plot = p, width = 10, height = 6, dpi = 300)