None of my attempts to use the scales to control alpha have been completely successful. My best attempt was to use ifelse
to control the value of a:
ggplot(xyd, aes(x=x, y=y, fill=z)) + geom_tile(aes(alpha=ifelse(a<=0.5, 0, a))) + scale_alpha(range=c(0,1))
So a different approach is required: remove the values that you do not want to display from the data:
xyd <- with(xyd, xyd[a>0.5, ]) ggplot(xyd, aes(x=x, y=y, fill=z)) + geom_tile(aes(alpha=a))
source share