效果不錯
效果圖.jpg
原理
對于穩定性強、解離度小,且只有一種配合物組成的配位比計算可以使用等摩爾系列法:
在溶液中保持的前提下,改變
和
的相對量,
當N值(
)達到最大時,即配合物
濃度最大,則
的值就是配合物的配位比
等摩爾系列法_2.png
繪圖實踐
原始數據在execl里,長這樣
原始數據.jpg
安裝和加載包
# 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="")
交點坐標.jpg
在初始點和交點之間生成一萬個點,讓圖像盡可能連續
# 創建擴展的數據點(只到交點)
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()