具有空数据点的列 [英] column with empty datapoints

查看:74
本文介绍了具有空数据点的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于具有空数据点的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆