Skip to content

Instantly share code, notes, and snippets.

@thomas-neitmann
Created May 19, 2020 17:21
Show Gist options
  • Save thomas-neitmann/93c4abd1188b2d933d9a6fcb4ce759ce to your computer and use it in GitHub Desktop.
Save thomas-neitmann/93c4abd1188b2d933d9a6fcb4ce759ce to your computer and use it in GitHub Desktop.
A Data Visualization of the GitHub Star History of the {ggcharts} R Package created with {ggplot2}
library(ggplot2)
Sys.setlocale("LC_TIME", "English")
stars <- ghstars::get_pkg_star_history("ggcharts")
stars <- stars[stars$date <= as.Date("2020-05-19"), ]
ggplot(stars, aes(date, cumulative_stars)) +
geom_step(color = "darkorange", size = 1.5) +
annotate(
geom = "label",
label = " 100th Star by @JagersbergKnut",
y = 75,
x = as.Date("2020-04-20"),
hjust = "right",
size = ggcharts:::pt2mm(20),
fill = "#A9A9B3",
color = "#292A2D",
label.padding = unit(.75, "lines")
) +
annotate(
geom = "curve",
x = as.Date("2020-04-20") + .25,
xend = as.Date("2020-05-18") - .75,
y = 80,
yend = 100,
curvature = -.2,
color = "#A9A9B3",
size = .75,
arrow = arrow(length = unit(3, "mm"))
) +
scale_x_date(
breaks = as.Date(c("2020-01-07", "2020-03-13", "2020-05-18")),
date_labels = "%B %e"
) +
scale_y_continuous(breaks = c(0, 25, 50, 75, 100)) +
labs(
x = NULL,
y = NULL,
title = "GitHub Star History of {ggcharts}",
caption = "Data Source: GitHub API. Imported into R using {ghstars}."
) +
ggcharts::theme_ng(base_size = 24, grid = "XY") +
theme(plot.caption = element_text(size = 14))
@thomas-neitmann
Copy link
Author

The plot can be seen here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment