
上QQ阅读APP看书,第一时间看更新
How to do it...
Let us get started with drawing bivariate dot plots using ggplot2:
- Use geom_dotplot() to draw a simple box plot:
> library(ggplot2)
> box1 <- ggplot(car::Salaries, aes( x = rank, y = salary))
> box1 + geom_dotplot(binaxis = 'y', dotsize = .3, stackdir = 'center')
As result, we get the following figure:

Figure 3.3 Simple ggplot2 dotplot.
- A third aspect can be visualized by picking aes(fill):
> box1 + geom_dotplot(binaxis = 'y', dotsize = .3,
> stackdir = 'center', aes(fill = sex))
Following figure shows that sex can now be visualized as graphic:

Figure 3.4 Dot plot with colors attached.
There are now some nuts and bolts to go through.