11 Advanced Plotting with ggplot – II
This chapter covers
- Making lollipop plots, Cleveland dot plots, and scatter plots
- Plotting distributions with histograms, box plots, violin plots, density plots, and ridgeline plots
- Customizing plot axes so that you can express these important plot elements to your own specifications
- Labeling interesting aspects of a plot with annotations
- Effective uses of color in plots
In the last chapter we focused on using ggplot to make line graphs and bar plots. That set the stage to having a closer look at customizing the plots until they were both aesthetically pleasing and presentation ready. In this chapter, we’ll revisit scatter plots, histograms, box plots, and possibly some you hadn’t heard of before. For those plots that ggplot just can’t do, there are other packages available that extend ggplot for those tasks (and we’ll use one called ggridges to make ridgeline plots). The examples in this chapter will expose you to new ggplot functions for customizing of plot elements such the axes and legends, and there will be more functions introduced for modifying the colors of plot objects.
In the many examples that follow, we’ll use datasets provided in the edr package. One of them was used before (nycweather) but the imdb and pitchfork datasets are new in this chapter and great fun to use! You can find out more about them within R by visiting their documentation pages (help(imdb) or help(pitchfork)).