R Data Visualization Recipes
上QQ阅读APP看书,第一时间看更新

Introduction

Often you may find yourself in a spot where you are willing to investigate the relationship between two variables, just like the Chapter 2, Plotting Two Continuous Variables did. The tools covered there are more suited for the continuous versus continuous paradigma, but sometimes you are stuck with a discrete versus continuous paradigma. If that is the case, this chapter may have what you're looking for.

This chapter introduces box, dot, and violin plots. Besides the mainly used functions to build them under ggplot2, ggvis, and plotly supervision, it also addresses some nuts and bolts that are usually related to this kinds of visualizations. Little tweaks that greatly improve the outcomes are also advised.

Two little disclaimers here. Sometimes, I may use categories as a pronoun for discrete values; I'm aware that they are not the same thing. Second disclaimer: by the time this chapter was written, plotly did not had functions to draw violins, nor did ggvis.

For ggvis and plotly packages, dot plots were achieved by using some sort of "hacks"; we will soon get to them. For that reason, the readers are going to see a lot more of ggplot2, only because this package is more mature. It's possible that some update had brought an easy way to design violin plots using ggvis or plotly, always look for updates. Now let's meet the data we're going to use a lot here.