【问题标题】:How to create an Excel-like smoothing in Gnuplot?如何在 Gnuplot 中创建类似 Excel 的平滑?
【发布时间】:2015-12-14 20:54:29
【问题描述】:

我得到的数据有很多数据点,没有明确的方程或只适合很多尖峰数据,我只想连接所有这些并使用 Gnuplot 创建一个平滑的图表,但是没有什么能像那些由 MS Excel 生成的。如何创建类似 Excel 的平滑图?

我使用的 Gnuplot 设置:

set terminal postscript eps enhanced font "FreeSerif,14" size 3.0in,1.7in
set output 'fig4a.eps'
set encoding iso_8859_1
set border linewidth .5
set xlabel '{/FreeSerif-BoldItalics d} {/FreeSerif-Bold ({\305})}'
set ylabel '{/FreeSerif-Bold {/Symbol D}{/FreeSerif-Bold C}_q (e/V)}'
set xrange [-8:8]
set xtics -8,2,8
set mxtics 2
set yrange [0:0.3]
set ytics 0,0.1,0.3
set mytics 2
set key at 1.42,-0.24 reverse
set style line 1 linewidth 0.5
plot for [n=2:4] 'fig4a.dat' u 1:n smooth cspline frequency w lines ls 1    
replot
quit

这些是我的图(设计有点不同,因为我仍在解决平滑问题) Excel

Gnuplot (spline, cspline, mcspline (每一个都产生相似的输出))

一些选定的数据点

使用:plot 'fig4a.dat' u 1:4 smooth cspline notitle w lines ls 1

输出:

数据点:

-8.09808994 -3.53E-07
-7.99108994 -1.02E-05
-7.88508994 -0.000162606
-7.77908994 -0.001377785
-7.67308994 -0.00552213
-7.56708994 -0.00499697
-7.46108994 0.0326345
-7.35408994 0.1168893
-7.24808994 0.186241
-7.14208994 0.205997
-7.03608994 0.191836
-6.93008994 0.151735
-6.82308994 0.106245
-6.71708994 0.086542
-6.61108994 0.104821
-6.50508994 0.155378
-6.39908994 0.192769
-6.29208994 0.17085
-6.18608994 0.133063
-6.08008994 0.093566
-5.97408994 0.091761
-5.86808994 0.171249
-5.76108994 0.20373
-5.65508994 0.139635
-5.54908994 0.117342
-5.44308994 0.142744
-5.33708994 0.111295
-5.23008994 0.047449
-5.12408994 0.017428002
-5.01808994 0.025381005
-4.91208994 0.07760701
-4.80608994 0.177550019
-4.69908994 0.221490023
-4.59308994 0.130530012
-4.48708994 0.022438001
-4.38108994 -0.004862101
-4.27508994 0.022498
-4.16908994 0.079377
-4.06208994 0.14604
-3.95608994 0.19269
-3.85008994 0.19097
-3.74408994 0.125244
-3.63808994 0.05851
-3.53108994 0.053151
-3.42508994 0.063857
-3.31908994 0.05646
-3.21308994 0.05375
-3.10708994 0.06817
-3.00008994 0.081894
-2.89408994 0.070248
-2.78808994 0.055941
-2.68208994 0.0445004
-2.57608994 0.029018
-2.46908994 0.034651
-2.36308994 0.05154
-2.25708994 0.051322
-2.15108994 0.053645993
-2.04508994 0.079479713
-1.93808994 0.110223123
-1.83208994 0.12952024
-1.72608994 0.123183
-1.62008994 0.100336
-1.51408994 0.0878377
-1.40708994 0.08143
-1.30108994 0.11223
-1.19508994 0.167822
-1.08908994 0.157034
-0.98308994 0.107838
-0.87708994 0.09736
-0.77008994 0.10481
-0.66408994 0.12359
-0.55808994 0.17554
-0.45208994 0.21844
-0.34608994 0.20774
-0.23908994 0.169731
-0.13308994 0.143784
-0.02708994 0.134956
0.07891006  0.136358
0.18491006  0.115993
0.29191006  0.1022772
0.39791006  0.130636
0.50391006  0.137051
0.60991006  0.108013
0.71591006  0.108763
0.82291006  0.147532
0.92891006  0.1658
1.03491006  0.160103
1.14091006  0.1589476
1.24691006  0.1353571
1.35391006  0.09032325
1.45991006  0.05464951
1.56591006  0.03587591
1.67191006  0.031322905
1.77791006  0.021403117
1.88491006  0.00489071
1.99091006  0.002355969

【问题讨论】:

  • 几件事:你的plot 行使用了错误的语法,应该是plot for [n=2:4] 'fig4a.dat' u 1:n smooth cspline ls 1 w lines。我们怎么知道 Excel 生成的绘图是什么样子的呢?请举个例子。并尝试不同的插值,例如smooth csplinesmooth beziersmooth mcspline
  • 嗨@Christoph,它只是错字。是的,cspline 不做平滑处理,bezier 将我的数据点减少为我认为的 4 度多项式,mcspline 也不做。
  • cspline 进行平滑处理,但没有看到任何更具体的示例(数据、当前结果、Excel 比较),继续猜测毫无意义......
  • 好的,仍然没有最小但完整的工作示例,其中包括数据文件的最小摘录(足以表明平滑失败)和最小脚本(只有一条绘图线,没有标签等),我只能猜测。正如您在我对smooth peaks in gnuplot 的回答中看到的那样,所有三个平滑选项都可以正常工作,除非您遇到一些奇怪的问题,例如你的数据文件格式,我不知道。
  • 我知道 gnuplot cspline,bezeir 做平滑,我之前在一些数据点上试过,它工作正常,但不是这个,我不能做任何平滑。我将更新我的帖子以显示一些数据点。

标签: graph gnuplot


【解决方案1】:

您可以设置在样条曲线中显示的点数

set sample 1000

【讨论】:

  • 哇!我不敢相信,1 行代码,然后 bam!光滑的!谢谢!现在可以了。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-07-17
  • 1970-01-01
  • 2023-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多