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
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 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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.