【发布时间】:2015-03-12 22:00:04
【问题描述】:
我编写了以下 R 脚本:
#energy diagram
x <- c(0.1, 0.3, 0.5, 0.7, 0.9 ) #chosen randomly, reaction axis
y <- c(-5.057920, -5.057859, -5.057887,-5.057674, -5.057919 ) #energy of the educt, intermediate, transtition states and product
plot(x,y, type="p",
xlim=c(0,1),
ylim=c(-5.058,-5.0575),
xlab="reaction axis",
ylab=expression(paste(E[el] ," / ",10^6," ",kJ/mol)),
xaxt="n" #hide x-axis
)
#h- and v-lines, so i can draw curves by hand
abline(v=seq(0,1,0.1),h=seq(-5.0600,-5.0500,0.00005),col="black",lty=1,lwd=1)
abline(h=c(-5.057920, -5.057859, -5.057887,-5.057674), col="blue", lty=1,lwd=0.7)
是否可以通过看起来像能量图的点绘制曲线。能量图的示例在这里:
【问题讨论】:
-
lines(spline(x, y))不幸的是不合适。 -
所以你提供的是最小/最大 (x,y) 对,这意味着你想要通过那些点的导数为 0 的点拟合曲线。样条线可以用于此,但我不知道任何标准的 R 实现也可以让您指定导数。
bezier包中的贝塞尔曲线可能会让您更幸运。这将允许您从最小/最大点水平添加“控制点”,这将在最小/最大点处强制执行 0 导数。 -
再看一点,
Hmisc::bezier似乎更容易使用。我现在没有太多时间,但如果仍然需要,我可以在一天左右的时间内找到解决方案。 -
没关系,我会把自己读成贝塞尔曲线。感谢您的信息:)