How to use ggplot2 to draw a stem plot?

Ask a question: how to use ggplot2 to draw stem- leaf graph like 'stem' function of MATLAB ?
The effect is shown in the following figure:

Easiest is probably geom_col. For the above, the mapping would just be aes(year, SPEI)

Or you could e.g. use geom_segment, with something like aes(x = year, y = 0, xend = year, yend = year). If you combine with geom_point you get something more like the examples here: Plot discrete sequence data - MATLAB stem, which we also call a lollipop chart.


Remember put and reproducible example for better help you.

# If data frame is data

dput( data[1:30, ]) # for select the 30 first rows and all the columns
1 Like

This topic was automatically closed 7 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.