head(run2)
Time5 Time15 Oxygen Tank Sulfide
1 0.000000000 0.00000000 7.553702 19.27838 2.79
2 0.001388889 0.00416667 7.573448 19.25815 2.75
3 0.002777778 0.00833334 7.540538 19.31884 2.83
4 0.004166667 0.01250001 7.553702 19.29861 2.81
5 0.005555556 0.01666668 7.543829 19.27838 2.80
6 0.006944444 0.02083335 7.563575 19.33907 2.83
p2 = ggplot() +
geom_line(data = run2, linetype="solid", aes(x = run2$Time5, y = run2$Oxygen), size = 2, color = "black") + scale_size_discrete(range = c(1, 2))+
geom_line(data = run2, linetype="longdash", aes(x = run2$Time15, y = run2$Tank), size = 2, color = "Black") + scale_size_discrete(range = c(1, 2))+
geom_line(data = run2, linetype="dotted", aes(x = run2$Time5, y = (run2$Sulfide)/49), size = 2, color = "black") + scale_size_discrete(range = c(1, 2))+
scale_x_continuous(expand = c(0, 0), breaks = c(0,1,2,3,4,5,6), limits = c(0,6)) +
scale_y_continuous(expand = c(0, 0), breaks = c(0,4,8,12,16,20), limits = c(0,20),
sec.axis=sec_axis(~.*50, breaks = c(200,400,600,800,1000),
name = expression(paste("Hydrogen Sulfide Concentration ( ", mu, "M H" [" 2"], "S)")))) +
labs(x = "",
y = "Oxygen Partial Pressure (kPa)",
subtitle = "(b)") +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"),
text=element_text(size=16, family="TT Arial"),
axis.text = element_text(family="TT Arial", size=12, colour="black")
)
I am trying to add a line type legend to this graph. The supplied code produces the graph from my data set. However, I need a legend to describe what each line means and everytime I try the scale_linetype or scale_colour functions I get nothing. I cant even get a legend to show up. I tried adding linetypes and colors to the aes function but that did not help either. I need the solid line to read "Oxygen", the dashed line to read "Tank water" and the dotted line to read "Sulfide". Please help!