Created
February 13, 2020 10:39
-
-
Save coolbutuseless/80f38842b9bdb0d591c66a65fcce950c to your computer and use it in GitHub Desktop.
stacking alpha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Simple function to create a plot with N overlapping rectangles with | |
# each having an alpha of 1/N | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
stack_alpha <- function(N) { | |
plot_df <- tibble( | |
x = seq(0.45, 0.55, length.out = N), | |
y = seq(0.45, 0.55, length.out = N), | |
alpha = 1/N | |
) | |
ggplot(plot_df) + | |
geom_tile(aes(x, y, alpha = I(alpha)), fill = 'black', | |
width=0.5, height = 0.5, colour = NA) + | |
theme_bw() | |
} | |
stack_alpha(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment