【问题标题】:Gnuplot: dealing with anomalous resultsGnuplot:处理异常结果
【发布时间】:2013-10-20 13:33:31
【问题描述】:

我在 Windows 8 机器上使用 gnuplot 版本 4.6,补丁级别 3,终端设置为 wxt。

文件 results.csv 有一个随球体半径变化的能量列表。我正在使用 Gnuplot 生成图表以显示趋势。

不幸的是,由于在用于计算这些能量的程序中只能描述为“数值不稳定性”,results.csv 包含异常结果。因此绘制 results.csv 与:

set datafile separator “,”
set title “Oxygen3 Point Vacancy Defect Energy Variation with \n Radius of Region I in Mott-Littleton Defect Model”
set xlabel ‘Radius of Region I (Å)’
set ylabel ‘Defect Energy (eV)’
set grid
unset key
set border 3
set xtics border nomirror outwards
set ytics border nomirror outwards
set format y '%.2f'
plot ‘results.csv’ using 2:4 smooth unique with linespoints lw 3 lc rgb ‘black’

给出下图:

[注意。我已经减少了这个例子的数据线数量]

由于我想要整体趋势,我想跳过半径 = 16 处的点。但是,将我的绘图命令更改为:

plot 'results.csv' using 2: ($4 > 20 ? $4 : 1/0) smooth unique with linespoints lw 3 lc rgb 'black'

结果:

有没有人对 gnuplot 将 x=9 点连接到 x=17 的原因以及如何克服这个问题提出任何建议。

另外,当我尝试拟合“最佳拟合线”时,如何跳过异常数据点?

任何帮助将不胜感激

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    绘图时忽略异常点

    原则上,gnuplot knowns

    1. missing 点,可以用set datafile missing 设置。这些点在绘图过程中会被跳过,不会影响线图。
    2. undefined 点,如 1/0。这些点也被跳过了,但线图在这里被打断了。

    不幸的是,当涉及计算(如您的案例中的过滤)时,无法使用丢失的数据点,请参阅例如In gnuplot, with “set datafile missing”, how to ignore both “nan” and “-nan”?.

    所以,最好的方法是使用外部工具来过滤数据:

    plot '< awk ''{ if ($4 > 20) print }'' results.csv' using 2:4 smooth unique
    

    但这要求进行平均的每个点都满足这个标准。

    拟合时忽略异常点

    关于在拟合过程中忽略异常点,我最近给Ignore points far away from mean gnuplot做了一个回答。

    我认为您可以在不进行平滑的情况下进行拟合,甚至可能比先平滑然后拟合更好。拟合平滑数据会忽略单个数据点的分布,以及单个数据点的保真度好/差。

    如果你还想使用平滑后的数据,你必须先将它们写入一个临时文件,因为smooth unique不能和fit一起使用:

    set output '| head -n -2 > results.tmp'
    set table
    plot '< awk ''{ if ($4 > 20) print }'' results.csv' using 2:4 smooth unique
    unset table
    

    关于set output 部分,请参阅Why does the 'set table' option in Gnuplot re-write the first entry in the last line?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-03
      • 1970-01-01
      • 1970-01-01
      • 2017-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多