I make graphs of environmental measurements along vertical profiles, for example. down the siege core or as a function of depth in the ocean. By convention, these graphs are presented vertically, with an independent variable (depth) along the y axis. Therefore, the lines should connect the points of the adjacent value of y.
The "line" geometry in ggplot2 seems to only connect the points of the adjacent x value. Is there any way around this?
This example creates some realistic 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)
You can see on this plot that we are looking at measurements related to depth. But:
connects the points in a meaningless way. Is there a way to tie the dots vertically?
source share