Geoms in lemon"

library(knitr)

knitr::opts_chunk$set(fig.height=4, fig.width=6,
                      cache=TRUE, autodep = TRUE, cache.path = 'geoms-cache/')

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')
grid.arrange(point, pointline)


Try the lemon package in your browser

Any scripts or data that you put into this service are public.

lemon documentation built on Nov. 7, 2023, 5:06 p.m.