【问题标题】:gnuplot data interpolation method for smoothing of data用于平滑数据的 gnuplot 数据插值方法
【发布时间】:2012-04-01 10:58:47
【问题描述】:

朋友们,我有大量数据要使用 gnuplot 打印在图表上。 由于图中的点数太大,我使用 cspline 数据插值方法来平滑数据。但是插值方法跳过了一些异常值,这些异常值在程序性能分析中可能很重要。我应该如何确保 gnuplot 函数不会遗漏极端异常值(相差超过 x 的值)。

这是我用来生成绘图的代码。

plot data_file binary format='%uint64 %double %double %double' using 1:2 smooth csplines title "Kernel hit-rate"  with lines, \ 
 data_file binary format='%uint64 %double %double %double' using 1:3 smooth csplines title "User hit-rate"    with lines, \
 data_file binary format='%uint64 %double %double %double' using 1:4 smooth csplines title "Overall hit-rate" with lines   

生成的图表如下:

我希望 gnuplot 只有在不太远的情况下才能平滑点(可配置参数)??您还可以建议任何其他可以满足我要求的绘图工具吗??

【问题讨论】:

  • 请不要进入图的语义。
  • 我很困惑,第一个情节是否带有 csplines 而第二个情节没有?如果是这样,您究竟想用 csplines 完成什么(即第二张图有什么问题?)
  • (1) 第一个图有 csplines,第二部分没有 csplines。 (2) 如您所见,在第二张图中,我们可以看到一些 y 值达到 0.8 到 0.9 。不幸的是,第一张图在 (5000) 附近的 x 范围的峰值约为 0.1
  • 但是第二个情节有什么问题?如果您想保留虚假峰值,似乎使用 csplines 与您想要完成的完全相反。 -- 作为旁注,使用set samples N 可用于增加您的采样频率,这可能会使第一个图看起来更像第二个图(具有相当大的 N)...
  • 此外,gnuplot 有多种平滑选项:来自内置帮助:` smooth {unique |频率 |累积 | k密度 | csplines | acsplines |贝塞尔 | sbezier}` -- 你可以试试其他的,看看效果如何。

标签: plot matplotlib gnuplot


【解决方案1】:

您可能可以通过结合使用 shell 魔法和set table 来完成此操作。例如:

set samples 200 #How many points will be used in interpolating the data...
YLIMIT=.5  #for example
set table 'junkfile1.dat'  #This holds the "smooth" portion
plot 'data_file' binary format='%uint64 %double %double %double' using 1:($2<YLIMIT ? $2: 1/0) smooth csplines
unset table                #This holds the "spurious" portion
set table 'junkfile2.dat'
plot 'data_file' binary format='%uint64 %double %double %double' using 1:($2>YLIMIT ? $2: 1/0)
unset table

plot '< sort -n -k 1 junkfile1.dat junkfile2.dat' u 1:2 with lines 
!rm junkfile1.dat junkfile2.dat  #cleanup after ourselves

(未测试)

【讨论】:

  • 问题是排序和其他功能仅适用于 ascii 数据,而不适用于二进制日期。我正在尝试修改图形格式并检查上面列出的代码。
  • 你指的是plot '&lt;sort -n -k 1 ...吗?设置表应输出 ASCII 数据文件(由 gnuplot 从您的二进制文件生成)。然后在最后一个绘图命令中将这些 ASCII 文件读回 gnuplot(在通过排序过滤数据后,应该接受 gnuplot 生成的 ASCII 文件。)
  • 我试过上面的方法。它适用于小输入,但对于较大的输入,它会崩溃并显示表的内存不足错误。
  • 哇,你真的必须有很多数据点(或少量内存)。我认为你应该问的问题是,你真的需要那么多数据吗?一旦你的点密度变得太高(例如,当你的点比屏幕上的像素多时),你并不能通过打包更多的点来获得太多。
猜你喜欢
  • 2021-06-15
  • 1970-01-01
  • 2012-12-04
  • 2013-01-22
  • 1970-01-01
  • 2022-01-13
  • 2016-03-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多