Geoms in lemon

Stefan McKinnon Edwards sme@iysik.com

2024-11-10

In this vignette, we will demonstrate the two geoms: geom_pointline and geom_siderange.

geom_pointline simply combines geom_point and geom_line, while geom_pointpath combines geom_point and geom_path. The difference is that geom_line draws its lines through the data points, geom_pointline leaves a small aesthetic gap between the symbol and the line:

library(ggplot2)
library(lemon)
library(gridExtra)

data(sunspot.year)
sunspots <- data.frame(count=as.numeric(sunspot.year), year=seq.int(start(sunspot.year)[1], end(sunspot.year)[1]))
sunspots <- subset(sunspots, year > 1900)

point <-  ggplot(sunspots, aes(x=year, y=count)) + geom_point() + geom_line() + labs(title='geom_point + geom_line')
pointline <- ggplot(sunspots, aes(x=year, y=count)) + geom_pointline(distance=unit(3, 'pt'), threshold=0.2) + labs(title='geom_pointline')
## Warning in geom_pointline(distance = unit(3, "pt"), threshold = 0.2):
## `geom_pointpath` and `geom_pointline` have been soft-deprecated. A replacement
## can be found in ggh4x::geom_pointpath.
grid.arrange(point, pointline)