'coloring points with extremely faint alpha
I want to plot a lot of points with extremely small alpha values in ggplot2. As I discovered in this question, the smallest possible alpha value in R is around 0.003.
Weirdly, at the smallest alpha value, while the points are still rendered, there is no color to them, and only as alpha values are being increased does color slowly appear. I'm not quite sure why this is happening.
library(tidyverse)
library(patchwork)
someData <- data.frame(x = rnorm(n = 100000),
y = rnorm(n = 100000))
p1 <- ggplot(someData) +
geom_point(aes(x = x, y = y), color = "#fbb4ae", alpha = (1/254.99) * 1)
p2 <- ggplot(someData) +
geom_point(aes(x = x, y = y), color = "#fbb4ae", alpha = (1/254.99) * 3)
p3 <- ggplot(someData) +
geom_point(aes(x = x, y = y), color = "#fbb4ae", alpha = (1/254.99) * 6)
p4 <- ggplot(someData) +
geom_point(aes(x = x, y = y), color = "#fbb4ae", alpha = (1/254.99) * 12)
print((p1+p2)/(p3+p4))
Weirdly, the plots look as expected if I use a color designation like so
p1 <- ggplot(someData) +
geom_point(aes(x = x, y = y), color = "red", alpha = (1/254.99) * 1)
p2 <- ggplot(someData) +
geom_point(aes(x = x, y = y), color = "red", alpha = (1/254.99) * 3)
p3 <- ggplot(someData) +
geom_point(aes(x = x, y = y), color = "red", alpha = (1/254.99) * 6)
p4 <- ggplot(someData) +
geom_point(aes(x = x, y = y), color = "red", alpha = (1/254.99) * 12)
print((p1+p2)/(p3+p4))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


