Box and dot plots can be combined in order to achieve a brand new visualization. Still employing the car::Salaries
data set framework, this recipe demonstrates how to bring them under the ggplot2
and plotly
labels. Audience gets more detailed information when boxes and combined with dots.
Again, we need the car
package locked and loaded:
> if( !require(car)){ install.packages('car')}
Data frame Salaries
will come from car
package.
Now let's combine box and dot plots:
- Combine
geom_boxplot()
andgeom_dotplot()
to reach the desired effect:
> library(ggplot2) ; library(car) > dot1 <- ggplot(Salaries, aes( x = rank, y = salary)) > dot1 + geom_boxplot(outlier.size = 0) + geom_dotplot(binaxis = 'y', dotsize = .3, stackdir = 'center', fill = 'red', alpha = .5)
Following image (Figure 3.6) shows boxes displayed beneath the dots:
Figure 3.6: Dot and box geometry combined.
plotly...