Plotting variability and confidence intervals better with ggdist
Confidence intervals are used to make inferences about a population based on a sample of data. They capture the variability of the data by providing a range of possible values for some parameter, rather than a single point estimate. The interval is a measure of how sure we are that the interval contains the true population parameter. It is common to show distributions and annotate them with range markers or confidence intervals. With this recipe, we will look at how to use ggplot
’s ggdist
extension to make informative and great-looking plots of distributions.
Getting ready
For this recipe, we need the ggdist
, ggplot2
, and palmerpenguins
packages.
How to do it…
We can create plots with confidence intervals as follows:
- Create a raincloud plot:
library(ggplot2)library(ggdist)library(palmerpenguins)ggplot(penguins) + aes(x = flipper_length_mm, y = island) + geom_dots...