I am trying to add a geom_tile layer to a plot without the filled color (just the outline). Is there a way to get a transparent tile where only the boundary is visible?
Thanks
If you only want the outlines as a single colour you can set fill = NA
, and then set the na.value
to NA
.data <- cbind(
expand.grid(x = 1:10, y = 1:10), z = runif(100))[sample(1:100,75), ]
ggplot(.data, aes(x = x, y = y)) + theme_bw() +
geom_tile(fill = NA, color = 'black', na.value = NA)
I think you are after alpha
parameter. Minimal example:
Create a plot with dummy data where you set color
(for "boundary") and no fill
:
p <- ggplot(pp(20)[sample(20*20, size=200), ], aes(x = x, y = y, color = z))
Add geom_tile()
with alpha
set to zero
:
p <- geom_tile(alpha=0)
Add theme_bw()
as transparent tiles look lame with a dark gray background :)
p + theme_bw()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With