具有空数据点的列

编程入门 行业动态 更新时间:2024-10-27 08:29:27
本文介绍了具有空数据点的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 date daily weekly monthly 1 11 88 2 12 3 45 44 4 54 5 45 6 45 66 7 77 8 78 9 71 99 88

对于每周列中的空数据点,该图正在绘制每月列中的值. 每月列图和每日列图非常理想. 除了设置数据文件缺少''并设置数据文件分隔符"\ t"

For empty data points in weekly column , the plot is ploting values from monthly column. Monthly column plot and daily column plot are perfect. suggest something more than set datafile missing ' ' and set datafile separator "\t"

推荐答案

A,Gnuplot不支持基于字段的数据文件,当前的唯一解决方案是对文件进行预处理. awk非常适合该任务(请注意,如果文件包含硬标签,则需要调整FIELDWIDTHS):

Alas, Gnuplot doesn't support field based data files, the only current solution is is to preprocess the file. awk is well suited for the task (note if the file contains hard tabs you need to adjust FIELDWIDTHS):

awk '$3 ~ /^ *$/ { $3 = "?" } $4 ~ /^ *$/ { $4 = "?" } 1' FIELDWIDTHS='6 7 8 7' infile > outfile

这用问号替换了第3列和第4列中的空白字段(/^ *$/),这意味着Gnuplot尚未定义. awk脚本末尾的1调用默认规则:{ print $0 }.

This replaces empty fields (/^ *$/) in column 3 and 4 with question marks, which means undefined to Gnuplot. The 1 at the end of the awk script invokes the default rule: { print $0 }.

如果将awk的输出发送到outfile,则可以例如现在绘制如下文件:

If you send awk's output to outfile, you can for example now plot the file like this:

set key autotitle columnhead out set style data linespoint plot 'outfile' using 1:2, '' using 1:3, '' using 1:4

更多推荐

具有空数据点的列

本文发布于:2023-11-05 19:44:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561676.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:据点

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!