I make plots of environmental measurements along vertical profiles, e.g. down a sediment core or as a function of depth in the ocean. By convention these plots are presented vertically, with the independent variable (depth) along the y axis. Lines should therefore connect points of adjacent y-value.
The "line" geom in ggplot2 seems only to connect points of adjacent x value. Is there a way around this?
This example creates some realistic-looking data and illustrates the problem:
#generate fake data
sites<-factor(c(rep("site A", 10), rep("site B", 10)))
depths<-rep(1:10, 2)
values<-c(runif(10), runif(10)+2)
#make a visually pleasing scatter plot
qplot(values, depths, geom="point", col=sites)
You can see from that plot that we're looking at measurements related by depth. But:
#make a visually meaningless scatter plot
qplot(values, depths, geom="line", col=sites)
connects the points in a meaningless way. Is there any way to connect the points vertically?
