Dotplots in ggplot2

I have some questions about making dotplots with {ggplot2}.

Is it possible to remove the dead space in a dotplot? Here's the very first example from the geom_dotplot() documentation.

ggplot(mtcars, aes(x = mpg)) +
    geom_dotplot()

Removing the part above the 0.50 point on the y-axis would improve the readability of the plot. Is this issue due to the "technical limitations" mentioned in the documentation?

The documentation also says "You can ... manually scale [the y-axis] to match the number of dots." How would this be done?

Reference: Dot plot — geom_dotplot • ggplot2

Thank you,
Michael L.

1 Like

@laviolet Hi, probably technical limitations. I tried this but the dead space fails to disappear. Please raise an issue to ggplot2. Thanks for sharing this.

ggplot(mtcars, aes(x = mpg)) +
geom_dotplot(stackdir = 'center') +
scale_y_continuous(limits = c(-0.50, 0.50), breaks = c(-0.25, 0.00, 0.25))

I tried that too, to no avail. Thanks for the response!

The limitation is that the dot plot shows stacked circles, each circle having the same width and height, equal to its diameter. In your example, the plot is 30 diameters wide (default binning in geom_dotplot()) and only 5 diameters tall, so the aspect ratio is about 30:5 or 6:1. In a typical plot with aspect ratio of 4:3, this forces the empty space above the dots. Otherwise the circles would be streched into ellipses. You can always change the aspect ratio of the plot:

Otherwise, I'd say that a stacked dot plot is not the best plot type in the world. I would use a histogram with bars to present the same result.

I agree that a dot plot isn't the first choice of graph, but this is for instruction and dot plots make a simple introduction leading to histograms. Thanks for the tip about aspect ratio.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.