Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gnuplot 绘制多变量时间数据_Gnuplot - Fatal编程技术网

Gnuplot 绘制多变量时间数据

Gnuplot 绘制多变量时间数据,gnuplot,Gnuplot,我有一些相当简单的数据,我想绘制,理想情况下是直方图或折线图,但我不知道怎么做 以下是一些示例数据: T Item Temp 1 Leaf 10 1 Car 12 2 Leaf 14 3 Car 23 4 Car 29 4 Leaf 30 在本例中,T是时间,Item是项目名称,Temp是项目此时的温度 我在尝试绘制此图表时遇到了一些问题: 项作为行而不是列进行跟踪 存在隐式零 如果我的数据为以下格式,则绘图会更容易,但不幸的是,它的格式不是这样的: T Car Leaf 1 1

我有一些相当简单的数据,我想绘制,理想情况下是直方图或折线图,但我不知道怎么做

以下是一些示例数据:

T Item Temp
1 Leaf 10
1 Car  12
2 Leaf 14
3 Car  23
4 Car  29 
4 Leaf 30
在本例中,T是时间,Item是项目名称,Temp是项目此时的温度

我在尝试绘制此图表时遇到了一些问题:

  • 项作为行而不是列进行跟踪
  • 存在隐式零
如果我的数据为以下格式,则绘图会更容易,但不幸的是,它的格式不是这样的:

T Car Leaf 
1 12  10
2 0   14
3 24  0
4 29  30

gnuplot是否能够绘制前一个示例,或者我是否必须编写一个预处理器来将提供的数据重新格式化为更简单易懂的第二个数据?

我相信这完全可以在gnuplot中完成。这将有助于您:

names=("Car Leaf")
plot for [name in names] 'test.txt' u 1:((stringcolumn(2)eq name?$3:0)) smooth freq with lp title name
键入
help smooth
help stringcolumn
了解更多信息

如果要自动填充
名称
变量,可以使用此
系统
命令:

names=system("awk '{print $2}' test.txt | tail -n +2 | sort | uniq")
对于
,这里有一个建议:

set boxwidth 0.5/(words(names))
plot for [i=0:words(names)] 'test.txt' u ($1-0.5-i/(words(names)+1.0)):((stringcolumn(2)eq word(names,i)?$3:0)) smooth freq with boxes title word(names,i)
这是你应该得到的:


我相信这完全可以在gnuplot中完成。这将有助于您:

names=("Car Leaf")
plot for [name in names] 'test.txt' u 1:((stringcolumn(2)eq name?$3:0)) smooth freq with lp title name
键入
help smooth
help stringcolumn
了解更多信息

如果要自动填充
名称
变量,可以使用此
系统
命令:

names=system("awk '{print $2}' test.txt | tail -n +2 | sort | uniq")
对于
,这里有一个建议:

set boxwidth 0.5/(words(names))
plot for [i=0:words(names)] 'test.txt' u ($1-0.5-i/(words(names)+1.0)):((stringcolumn(2)eq word(names,i)?$3:0)) smooth freq with boxes title word(names,i)
这是你应该得到的: