效果不错
原理
对于稳定性强、解离度小,且只有一种配合物组成的配位比计算可以使用等摩尔系列法:
在溶液中保持的前提下,改变和的相对量,
当N值()达到最大时,即配合物浓度最大,则的值就是配合物的配位比
绘图实践
原始数据在execl里,长这样
安装和加载包
# install.packages("ggplot2")
# install.packages("readxl")
library(ggplot2)
library(readxl)
读取文件,用前三个和后三个点拟合出直线
record = read_excel("C:/Users/Administrator/Desktop/磺基水杨酸吸光度.xlsx")
record = as.data.frame(lapply(record[, 3:4], as.numeric))
first_three <- record[1:3, ]
last_three <- record[(nrow(record) - 2):nrow(record), ]
提取斜率和截距算交点
lm_first <- lm(A ~ N, data = first_three)
lm_last <- lm(A ~ N, data = last_three)
# 提取模型的斜率和截距
slope_first <- coef(lm_first)[2]
intercept_first <- coef(lm_first)[1]
slope_last <- coef(lm_last)[2]
intercept_last <- coef(lm_last)[1]
# 计算交点
x_intersection <- (intercept_last - intercept_first) / (slope_first - slope_last)
y_intersection <- slope_first * x_intersection + intercept_first
输出交点坐标可以用这句cat("交点坐标为: (", x_intersection, ", ", y_intersection, ")\n", sep="")
在初始点和交点之间生成一万个点,让图像尽可能连续
# 创建扩展的数据点(只到交点)
x_first <- seq(min(first_three$N), x_intersection, length.out = 10000)
y_first <- slope_first * x_first + intercept_first
x_last <- seq(x_intersection, max(last_three$N), length.out = 10000)
y_last <- slope_last * x_last + intercept_last
# 将直线数据放入dataframe中
line_first <- data.frame(N = x_first, A = y_first)
line_last <- data.frame(N = x_last, A = y_last)
画图,一共六个元素:原始数据点、曲线、拟合直线两条、交点、交点坐标和理论最大值(浓度比为0.5)的坐标
ggplot(data = record, aes(x = N, y = A)) +
geom_point() +
labs(title = "磺基水杨酸物质的量分数和吸光度",
x = "磺基水杨酸/(磺基水杨酸+铁离子)",
y = "吸光度") +
geom_smooth(method = "loess", se = FALSE, span = 0.5, na.rm = T, color = "cornflowerblue", linewidth = 0.9) +
annotate("point", x = x_intersection, y = y_intersection, color = "red", size = 3) +
annotate("text", x = x_intersection, y = y_intersection,
label = paste("(", sprintf("%.2f", x_intersection), ", ", sprintf("%.2f", y_intersection), ")", sep = ""),
hjust = -0.3, color = "red") +
annotate("text", x = record$N[6], y = record$A[6],
label = paste("(", sprintf("%.2f", record$N[6]), ",", sprintf("%.2f", record$A[6]), ")", sep = ""),
vjust = -0.9) +
geom_line(data = line_first, aes(x = N, y = A), color = "red", linetype = "dashed", size = 0.5) +
geom_line(data = line_last, aes(x = N, y = A), color = "red", linetype = "dashed" , size = 0.5) +
theme_minimal()