This seems to be a duplicate of R - ggplot geom_step error, which has not been answered yet.
When the data to plot consists of one point only, geom_step
throws an error while geom_line
gives a warning only:
library(ggplot2)
data <- data.frame(x = 1, y = 2)
# works
ggplot(data = data, aes(x = x, y = y)) + geom_line()
# does not work
ggplot(data = data, aes(x = x, y = y)) + geom_step()
geom_step
gives the error message: invalid line type
. Is this a bug or the desired behaviour? With this behaviour geom_step
looses a part of ggplot
's flexibility since the single point case needs to be dealt with manually. One brute force solution is to manually check for number of points to be plotted and only add the step-layer if there are at least two point. But surely there must be a more elegant workaround?!
packageVersion("ggplot2")
[1] ‘1.0.1’