Skip to content

Instantly share code, notes, and snippets.

View z3tt's full-sized avatar
👨‍💻
Coding at home

Cédric Scherer z3tt

👨‍💻
Coding at home
View GitHub Profile
@z3tt
z3tt / imp_berlin.R
Last active November 22, 2022 03:53
Imperviousness levels in and around Berlin, Germany
library(tidyverse)
library(sf)
library(terra)
library(stars)
library(ggspatial)
library(systemfonts)
library(patchwork)
register_variant(
name = "Input Mono Light",
@z3tt
z3tt / human-rights-protection-scores.R
Created December 29, 2022 18:51
Human Rights Protection Scores of USA and Germany
## packages
library(ggplot2)
library(dplyr)
library(tidyr)
library(ggbraid)
library(colorspace)
library(owidR)
# plus ggtext via namespace
@z3tt
z3tt / basic-gauge-ggplot.R
Created July 23, 2025 15:30
A basic gauge chart made with ggplot2 + coord_radial()
library(ggplot2)
value <- 7.3
ggplot() +
# Add gap to bottom
coord_radial(
start = 4/3 * pi, # 240°
end = 2/3 * pi, # 120°
expand = FALSE
@z3tt
z3tt / photo-palette.R
Created October 16, 2025 08:50
Recolor images using any palette
library(ggplot2)
library(patchwork)
# get photo
img <- magick::image_read("https://www.yan-holtz.com/img/team/YH_pic_square.png")
# retrieve lightness
c <- magick::image_channel(img)
img_df <- tibble::as_tibble(as.data.frame.table(drop(as.integer(c[[1]]))))
img_df <- dplyr::mutate(img_df, across(c(Var1, Var2), as.numeric))
@z3tt
z3tt / population-treemap.R
Created October 23, 2025 12:32
A treemap of the world’s population by continent
library(ggplot2)
library(treemapify)
library(ggtext)
library(prismatic)
owid_urban <- readr::read_csv("https://www.ggplot2-uncharted.com/data/hyde.csv")
treemap <- owid_urban |>
sf::st_drop_geometry() |>
filter(!is.na(continent)) |>