Skip to content

Instantly share code, notes, and snippets.

@z3tt
Last active July 29, 2020 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z3tt/654b11018c5550492087709d71e431f5 to your computer and use it in GitHub Desktop.
Save z3tt/654b11018c5550492087709d71e431f5 to your computer and use it in GitHub Desktop.
Test transparency geom_point()
library(tidyverse)
library(patchwork)
df <- tibble(x = 1, y = 1)
g <- ggplot(df, aes(x, y)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
coord_cartesian(clip = "off") +
theme_void() +
theme(plot.title = element_text(hjust = .5))
p1 <- g +
geom_point(size = 100) +
ggtitle("geom_point(alpha = 1, shape = 19)\n(DEFAULT)")
p2 <- g +
geom_point(size = 100, alpha = .2, stroke = 5) +
ggtitle("geom_point(alpha = .2, shape = 19)\n")
p3 <- g +
geom_point(size = 100, alpha = .2, stroke = 5, shape = 16) +
ggtitle("geom_point(alpha = .2, shape = 16)\n")
p4 <- g +
geom_point(size = 100, alpha = .2, stroke = 5, shape = 21, fill = "black") +
ggtitle("geom_point(alpha = .2, shape = 21, fill = 'black')\n")
p5 <- g +
geom_point(size = 100, stroke = 5, color = "#00000033") +
ggtitle("geom_point(color = '#00000033')\n")
p6 <- g +
geom_point(size = 100, stroke = 5, shape = 21, color = "#000000", fill = "#00000033") +
ggtitle("geom_point(shape = 21, color = '#000000', fill = '#00000033')\n")
p1 + p2 + p3 + p4 + p5 + p6
ggsave("points.pdf", width = 16, height = 8, device = cairo_pdf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment