Dealing with over-plotting, alpha blending
Another popular technique is known as alpha blending. It consists on making points translucent, this way the audience gets to know if points are stacked or not. Between all the techniques demonstrated so far, alpha blending must be the most popular one. This recipe teaches how to apply alpha blending using ggplot2
, plotly
, and ggvis
.
How to do it...
- Set the
alpha
parameter to apply alpha blending toggplot
:
> library(ggplot2) > sca1 <- ggplot( iris, aes( x = Petal.Length, y = Petal.Width)) > sca1 + geom_point( alpha = .5 , aes(shape = Species, colour = Species))
The following figure 2.7 shows alpha blending working:
Figure 2.7 - alpha blending with ggplot2.
- Setting
alpha
parameter withplotly
will also apply alpha blending:
> library(plotly) > sca9 <- plot_ly( iris, x = ~Petal.Length, y = ~Petal.Width, > type = 'scatter', mode = 'markers', alpha = .5, symbol = ~Species) > sca9
ggvis
applies...