How To Make Dumbbell Plot in R with ggplot2?
The Dumbbell Plot shows the change between two points in our dataset. It is named so because of its Dumbbell shape. It helps us to understand the span of data categorically. To make Dumbbell Plot in R using ggplot2, we use the geom_dumbbell() function.
Syntax: geom_dumbbell(data, aes(y, x, xend), size, color, size_x, size_xend, colour_x, colour_xend)
- data: Data frame for plotting data
- size: Size of bar in dumbbell
- color: Color of bar in dumbbell
- size_x: Size of first circle in plot
- colour_x: Colour of first circle in plot
- size_xend: Size of second circle in plot
- colour_xend: Colour of second circle in plot
With ggplot2, Dumbbell plots can be built using geom_dumbbell() function. At least three variables must be provided to aes() that are y, x, and xend.
Creating basic dumbbell plot
Here is a basic dumbbell plot using the ggplot2 package.
Customizing Size in Dumbbell Plot:
We can customize the dumbbell plot by changing the radius of the circle in the dumbbell plot or the width of the segment between.
Customizing Color in Dumbbell Plot:
We can customize color in the dumbbell plot by using color_x and color_xend properties.