library(ggplot2)
library(cowplot)
##
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggplot2':
##
## ggsave
NaOH_CH3COOH = c(seq(1*10^-2.9,0.1,by=0.0001))
# c[AH] = 1-NaOH_CH3COOH (fully protonated CH3COOH dissociates as we add more NaOH)
# c[A-] = NaOH_CH3COOH (amount of deprotonated CH3COOH is equal(?) to the amount of added NaOH)
cH_CH3COOH = 10^-((4.76-log10((0.1-NaOH_CH3COOH)/NaOH_CH3COOH)))
cH_CH3COOH[length(cH_CH3COOH)] = 10^-13
NaOH_HCL = c(seq(0,10^-2,by=0.000001),seq(10^-2,0.1,by=0.001))
#cH_HCl = 10^-2.4-NaOH_HCL
cH_HCl = 10^-((14 + log10(NaOH_HCL + 10^-(14-2.875))))
#cH_HCl[length(cH_HCl)] = 10^-10
g1 = ggplot() +
geom_line(aes(x=NaOH_HCL, y=cH_HCl), color="green") +
geom_point(aes(x=0,y=cH_CH3COOH[1]), color="red") +
geom_line(aes(x=NaOH_CH3COOH-NaOH_CH3COOH[1], y=cH_CH3COOH),col="red") +
coord_cartesian(ylim=c(-0.00001, 0.0015), xlim=c(-0.00000001, 0.00002), expand = F) +
xlab("[OH-]") +
ylab("[H+]") +
theme_bw()
g2 = ggplot() +
geom_line(aes(x=NaOH_HCL, y=-log10(cH_HCl)), color="green") +
geom_point(aes(x=0,y=-log10(cH_CH3COOH[1])), color="red") +
geom_line(aes(x=NaOH_CH3COOH-NaOH_CH3COOH[1], y=-log10(cH_CH3COOH)),col="red") +
coord_cartesian(ylim=c(2, 14), xlim=c(-0.001,0.101), expand = F) +
xlab("[OH-]") +
ylab("pH") +
theme_bw()
ggdraw()+
draw_plot(g1, x=0, y=0, width=0.5, height=1) +
draw_plot(g2, x=0.5, y=0, width=0.5, height=1)
