Deprecation notice: The
geom_pointline and geom_pointpath
have been deprecated in
lemon v. 0.5.0. Instead, we refer to the similar geom in ggh4x.
In this vignette, we will demonstrate the two geoms: geom_pointpath 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(ggh4x)
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_pointpath(mult = 0.4) + labs(title = 'ggh4x geom_pointline')
grid.arrange(point, pointline)
The geom geom_pointpath
in ggh4x can be used as
replacement for both lemon’s geom_pointline
and
geom_pointpath
:
lemon | ggh4x |
---|---|
|
The |
The geom_siderange
projects data onto the horizontal or
vertical edge of the panels.
library(lemon)
x <- rnorm(25)
df <- data.frame(x = x, y = x + rnorm(25, sd = 0.2),
a = sample(c("horse", "goat"), 25, replace = TRUE),
stringsAsFactors = FALSE)
df$y <- with(df, ifelse(y > 1 & a == 'horse', 1, y))
p <- ggplot(df, aes(x = x, y = y, colour = a)) + geom_point(shape = 1)
p + geom_siderange(start = 19)
Capping the sideranges with different symbols:
It also works with facets:
p <- ggplot(mpg, aes(displ, hwy, colour = fl)) +
geom_point() +
facet_wrap(~class, nrow = 4)
p + geom_siderange()