Friday, May 2, 2014

ggplot2: difference between geom_line and geom_path

geom_line: Connect observations, ordered by x value.

geom_path: Connect observations in original order

demo geom_line and geom_path
Double click to toggle code
plotdata = data.frame(x=c(1, 4, 3, 2), y=c(2, 3, 2, 1))
plotdata = plotdata + matrix(1.5*runif(8), 4)
myplot = ggplot(plotdata, aes(x, y)) + geom_line()
print(myplot)
myplot = ggplot(plotdata, aes(x, y)) + geom_path()
print(myplot)

0 comments: