Skip to content

Instantly share code, notes, and snippets.

@gdkrmr
Created May 6, 2019 12:53
Show Gist options
  • Save gdkrmr/586ab2d88c9399395c2ed002fb99cacf to your computer and use it in GitHub Desktop.
Save gdkrmr/586ab2d88c9399395c2ed002fb99cacf to your computer and use it in GitHub Desktop.
Create a bivariate color map after Teuling et al. (2011)
using Images, Interpolations
bar_corners(a) = [
RGB(0, 0.5, 1) RGB(1 - a, 0, 1 - a);
RGB(a, 1, a) RGB(1, 0.5, 0)
]
function color_bar(n, a)
aint = interpolate(bar_corners(a), BSpline(Linear()))
[aint(i, j) for i in range(1, 2, length = n), j in range(1, 2, length = n)]
end
function whitening_kernel(n)
xx = range(-1, 1, length = n)
Gray.(0.5 .- sqrt.((xx .^ 2 .+ xx' .^ 2) ./ 8))
end
seq_color_bar(n, a) = color_bar(n, a)
div_color_bar(n, a) = color_bar(n, a) .+ whitening_kernel(n)
seq_color_bar(5, 0.37) |> display;
div_color_bar(5, 0.37) |> display;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment