I am plotting salinity with depth in ggplot2, and I would like my geom_line to follow the data points along the y axis and not x axis.
This is what a sample of my data looks like:
Depth Salinity
0 28.81
.25 28.93
.5 28.92
.75 28.92
1 28.92
1.25 28.93
1.5 28.93
1.75 28.94
2 28.94
And this is the code I use...
ggplot(YSIData,aes(Salinity.1,-Depth))+
geom_point(aes(Salinity.1,-Depth,color="Profile 1"))+
geom_line()
...to generate this graph (there are more data points in this graph past 2 meters) Depth vs Salinity
But I don't want the line to go from left to right, I want it to follow the points from top to bottom (aka the order in which they were collected). How would I change the way geom_line follows the path of my data points?