I'm trying to replicate this graph I made in Excel here with ggplot. My Data is included here. I have many of the same Excel files that I'd like to make these graphs with as a big batch, otherwise I would just use Excel. I can make the graph very similarly in ggplot with the code below, but I don't know how to make the secondary x axis like I have in Excel to make the graph look right. I'd also like to make the one column in the data that says "System UpLoad Time = Jul 25 2017 18:53:32" as the title of the graph. Is there any way to do this easily?
dat.m <- melt(TestData, id=c ("Depth", "Temp", "Specific Conductance [µS/cm]", "FlECO-AFL", "Beam Attenuation (1/m)",
"Beam Transmission (%)", "Transmissometer voltage",
"Fluorometer voltage", "CDOM Voltage", "CDOM (mg/m^3)", "Flag"))
ggplot(dat.m, aes(value, Depth, colour = variable)) +
geom_point() + scale_y_reverse()
EDITS:: I have figured out how to make the graph, thanks for the additional links. Is there a way to add what is in a cell of my data to be included in the title or someplace on the graph? The column that says "System UpLoad Time = Jul 25 2017 18:53:32" is important and needs to be on the graph, though not necessarily the title
The new code is here:
dat.m <- melt(TestData, id=c ("Depth", "Temp", "Temp2", "Specific Conductance [µS/cm]", "FlECO-AFL", "Beam Attenuation (1/m)",
"Beam Transmission (%)", "Transmissometer voltage",
"Fluorometer voltage", "CDOM Voltage", "CDOM (mg/m^3)", "Flag", "Derivedchlorophyll"))
plot<-ggplot(dat.m, aes(value, Depth, colour = variable)) +
geom_point() + scale_y_reverse()
plot+ scale_x_continuous(
"PAR",
sec.axis = sec_axis(~ . / 56, name = "Chlorophyll
Temp")
)