将曲线很好地拟合到 gnuplot 或其他程序中的点?
Good fitting a curve to the points in gnuplot or maybe in other program?
我有一个大问题。我想非常好地通过这些点获得最佳拟合曲线。在 gnuplot 中我试试这个。
f(x) = a*x**6 + b*x**5 + c*x**4 + d*x**3 + e*x**2 + f*x + g
fit f(x) 'dihedral_energy_sorted.txt' via a, b, c, d, e, f, g
plot 'dihedral_energy_sorted.txt' with points pointtype 7 pointsize 2 linecolor "red", 'dihedral_energy_sorted.txt' with lines lw 2 linecolor "red", f(x) with lines lw 2 linecolor "blue"
但是我的成绩不是很好
我需要更好的东西,它给了我一个通过点的折线图,而且更平滑,而不仅仅是由线连接的点。
也许在 excel 或 matplotlib 中我有一些可以帮助我的东西
我需要这样的衣服
这是第一个文件的数据
-172.266 5.93362
-161.743 7.90223
-151.444 9.39198
-139.667 9.07427
-128.472 7.94997
-118.986 6.82431
-109.593 5.48811
-99.149 4.25969
-89.297 3.26822
-78.018 2.26675
-69.572 1.43405
-59.157 0.814157
-50.830 0.57777
-40.542 0.859919
-30.995 1.28429
-21.507 1.70913
-11.557 2.41328
-0.911 3.12653
9.526 3.97824
19.606 4.61242
29.856 5.27657
40.725 5.0631
51.336 3.71232
61.068 2.25515
70.685 1.25386
80.499 0.655369
90.433 0.332484
100.257 0.167369
110.170 0.156063
120.393 0
129.920 0.100962
140.245 0.258918
149.617 0.698804
158.873 1.52595
168.424 2.53915
178.232 4.08872
这是第二个文件的数据
-172.266 106.470
-161.743 106.362
-151.444 105.361
-139.667 105.809
-128.472 108.023
-118.986 111.368
-109.593 115.765
-99.149 119.263
-89.297 121.257
-78.018 120.227
-69.572 118.617
-59.157 116.109
-50.830 115.423
-40.542 114.353
-30.995 113.756
-21.507 113.016
-11.557 112.750
-0.911 111.413
9.526 110.081
19.606 109.232
29.856 108.139
40.725 110.666
51.336 111.101
61.068 111.435
70.685 110.908
80.499 110.659
90.433 110.070
100.257 109.833
110.170 109.453
120.393 109.125
129.920 108.426
140.245 108.150
149.617 107.904
158.873 107.596
168.424 107.216
178.232 106.899
根据SO-“规则”,评论中没有答案:这是一个答案。检查 help smooth
和 splines
选项之一。
有了这么多点,不同的 splines
选项差别不大。
代码:
### smooth slpines
reset session
$Data <<EOD
-172.266 106.470
-161.743 106.362
-151.444 105.361
-139.667 105.809
-128.472 108.023
-118.986 111.368
-109.593 115.765
-99.149 119.263
-89.297 121.257
-78.018 120.227
-69.572 118.617
-59.157 116.109
-50.830 115.423
-40.542 114.353
-30.995 113.756
-21.507 113.016
-11.557 112.750
-0.911 111.413
9.526 110.081
19.606 109.232
29.856 108.139
40.725 110.666
51.336 111.101
61.068 111.435
70.685 110.908
80.499 110.659
90.433 110.070
100.257 109.833
110.170 109.453
120.393 109.125
129.920 108.426
140.245 108.150
149.617 107.904
158.873 107.596
168.424 107.216
178.232 106.899
EOD
plot $Data u 1:2 w p pt 7 ti "Data", \
'' u 1:2 smooth csplines lc "red" ti "csplines", \
'' u 1:2 smooth acsplines lc "green" ti "acsplines", \
'' u 1:2 smooth mcsplines lc "blue" ti "mcsplines"
### end of code
结果:
我有一个大问题。我想非常好地通过这些点获得最佳拟合曲线。在 gnuplot 中我试试这个。
f(x) = a*x**6 + b*x**5 + c*x**4 + d*x**3 + e*x**2 + f*x + g
fit f(x) 'dihedral_energy_sorted.txt' via a, b, c, d, e, f, g
plot 'dihedral_energy_sorted.txt' with points pointtype 7 pointsize 2 linecolor "red", 'dihedral_energy_sorted.txt' with lines lw 2 linecolor "red", f(x) with lines lw 2 linecolor "blue"
但是我的成绩不是很好
我需要更好的东西,它给了我一个通过点的折线图,而且更平滑,而不仅仅是由线连接的点。
也许在 excel 或 matplotlib 中我有一些可以帮助我的东西
我需要这样的衣服
这是第一个文件的数据
-172.266 5.93362
-161.743 7.90223
-151.444 9.39198
-139.667 9.07427
-128.472 7.94997
-118.986 6.82431
-109.593 5.48811
-99.149 4.25969
-89.297 3.26822
-78.018 2.26675
-69.572 1.43405
-59.157 0.814157
-50.830 0.57777
-40.542 0.859919
-30.995 1.28429
-21.507 1.70913
-11.557 2.41328
-0.911 3.12653
9.526 3.97824
19.606 4.61242
29.856 5.27657
40.725 5.0631
51.336 3.71232
61.068 2.25515
70.685 1.25386
80.499 0.655369
90.433 0.332484
100.257 0.167369
110.170 0.156063
120.393 0
129.920 0.100962
140.245 0.258918
149.617 0.698804
158.873 1.52595
168.424 2.53915
178.232 4.08872
这是第二个文件的数据
-172.266 106.470
-161.743 106.362
-151.444 105.361
-139.667 105.809
-128.472 108.023
-118.986 111.368
-109.593 115.765
-99.149 119.263
-89.297 121.257
-78.018 120.227
-69.572 118.617
-59.157 116.109
-50.830 115.423
-40.542 114.353
-30.995 113.756
-21.507 113.016
-11.557 112.750
-0.911 111.413
9.526 110.081
19.606 109.232
29.856 108.139
40.725 110.666
51.336 111.101
61.068 111.435
70.685 110.908
80.499 110.659
90.433 110.070
100.257 109.833
110.170 109.453
120.393 109.125
129.920 108.426
140.245 108.150
149.617 107.904
158.873 107.596
168.424 107.216
178.232 106.899
根据SO-“规则”,评论中没有答案:这是一个答案。检查 help smooth
和 splines
选项之一。
有了这么多点,不同的 splines
选项差别不大。
代码:
### smooth slpines
reset session
$Data <<EOD
-172.266 106.470
-161.743 106.362
-151.444 105.361
-139.667 105.809
-128.472 108.023
-118.986 111.368
-109.593 115.765
-99.149 119.263
-89.297 121.257
-78.018 120.227
-69.572 118.617
-59.157 116.109
-50.830 115.423
-40.542 114.353
-30.995 113.756
-21.507 113.016
-11.557 112.750
-0.911 111.413
9.526 110.081
19.606 109.232
29.856 108.139
40.725 110.666
51.336 111.101
61.068 111.435
70.685 110.908
80.499 110.659
90.433 110.070
100.257 109.833
110.170 109.453
120.393 109.125
129.920 108.426
140.245 108.150
149.617 107.904
158.873 107.596
168.424 107.216
178.232 106.899
EOD
plot $Data u 1:2 w p pt 7 ti "Data", \
'' u 1:2 smooth csplines lc "red" ti "csplines", \
'' u 1:2 smooth acsplines lc "green" ti "acsplines", \
'' u 1:2 smooth mcsplines lc "blue" ti "mcsplines"
### end of code
结果: