I am trying to recreate a geological cross section similar to the one below, which show various rock parameters (x axis) plotted against depth (y axis)
I can nicely recreate the individual plots in ggplot2 and grid together to create something very similar. To finish off i would really like to join lines between the plots which show regions of similar geology as in the picture.
Below is some code which plots the charts with the horizontal lines, what i would really to do is to join lines ( if possible in R) and if possible align the charts based on the line
library(ggplot2)
library(gridExtra)
df1 = data.frame(replicate(2,sample(0:200,100,rep=TRUE)))
df1$depth = seq.int(nrow(df1))
df2 = data.frame(replicate(2,sample(0:200,100,rep=TRUE)))
df2$depth = seq.int(nrow(df1))
top1 = 32
top2 = 50
plot1 = ggplot(df1, aes(y = depth, x = X1))+
scale_y_continuous(trans = "reverse")+
geom_path()+
geom_hline(yintercept=top1, colour = "red")+
annotate(geom="text", x=25, y=top1, label=top1, color="red")+
theme_bw()+
theme(panel.grid.major = element_line(colour = "grey"), panel.background = element_rect(colour = "black", size=0.5))+
ylab("Depth ft")+
ggtitle("plot1")
plot2 = ggplot(df2, aes(y = depth, x = X1))+
scale_y_continuous(trans = "reverse")+
geom_path()+
geom_hline(yintercept=top2, colour = "red")+
annotate(geom="text", x=25, y=top2, label=top2, color="red")+
theme_bw()+
theme(panel.grid.major = element_line(colour = "grey"), panel.background = element_rect(colour = "black", size=0.5))+
ylab("Depth ft")+
ggtitle("plot2")
grid.arrange (plot1, plot2, ncol=2)
This would be the desired result i would be looking for with the lines joined and if possible aligned.
Thanks for any help or advice given
Cheers