Skip to content

Instantly share code, notes, and snippets.

@TonyLadson

TonyLadson/ARF_map.R

Created May 12, 2020
Embed
What would you like to do?
library(tidyverse)
xdf <- tribble(~area_min, ~area_max, ~dur_min, ~dur_max, ~type,
10, 1000, 0, 12, 'short',
10, 30000, 24, 168, 'long',
10, 30000, 12, 24, 'interpolation',
0, 1, 0, 168, 'ARF = 1',
1, 10, 0, 12, 'Interp3',
1, 10, 12, 24, 'Interp2',
1, 10, 24, 168, 'Interp1')
my_size <- 3
my_labels <- tribble(~x, ~y, ~label, ~hjust, ~angle,
100, 6, 'Short duration', 'left', 0,
1000, 18, 'Interpolate between short and long durations', 'center', 0,
1000, 96, 'Long duration', 'center', 0,
0.4, 100, 'ARF = 1', 'center', 90,
4, 100, 'Interpolate 1', 'center', 0,
4, 18, 'Interpolate 2', 'center', 0,
4, 6, 'Interpolate 3', 'center', 0,
3000, 6, 'No guidance', 'center', 0)
ggplot() +
geom_rect(data = xdf, aes(xmin = area_min,
xmax = area_max,
ymin = dur_min,
ymax = dur_max,
fill = type),
colour = 'black') +
scale_x_continuous(name = bquote('Catchment Area'~km^2),
trans = 'log1p',
breaks = c(0, 1, 10, 1000, 30000), labels = c('0', '1', '10','1000', '30,000')) +
scale_y_continuous(name = 'Duration (hours)', breaks = c(0, 12, 24, 168)) +
scale_fill_brewer(palette = "Blues") +
theme_classic(base_size = 12) +
geom_label(data = my_labels, aes(x = x, y = y, label = label, hjust = hjust, angle = angle), size = my_size) +
guides(fill = 'none') +
NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment