Gnuplot:将按行命名的数据绘制为成束的不同颜色和标题的行 [英] Gnuplot: Plot row-wise and named data as bundle of differently colored and titled lines

查看:51
本文介绍了Gnuplot:将按行命名的数据绘制为成束的不同颜色和标题的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制当前以这种方式存储的一组图形:

MyFile.txt

MyFile.txt

"ID01" 1 2 3 4 5
"ID02" 3 4 5 6 7 8 9
"ID03" 4 3 1 2 3 4

,因此有一行标题为"ID01"的行仅显示第一行,另一行标题为"ID02",依此类推.如果线条以不同的颜色显示,则奖励积分.任何帮助深表感谢!

such that there is one line titled "ID01" that shows the first row only, another line titled "ID02" and so on. Bonus points if lines are displayed in different colors. Any help is much appreciated!

我已经了解到了:

plot for[blockIndex=0:3] "MyFile.txt" matrix index blockIndex every ::1 w lp title "".blockIndex

如果在数据文件的行之间插入空白行,则将生成以下图像(我可以这样做).

which produces the below image if blank lines are inserted between rows in the data file (which I could do).

剩下的问题是

a)我绝对不会获得ID字符串来显示为标题(columnheader显然在矩阵模式下不能很好地播放).我当前使用的块索引是权宜之计,但不是完成脚本的选项.我确实可以选择以不同的方式在数据文件中排列ID字符串(即,按columnheader单独添加注释行,...)-唯一的要求实际上是所有行数据都应位于单个文件中.

a) I absolutely do not get the ID-String to display as the title (columnheader apparently does not play well with matrix mode). I currently use the block index, which would work as a stopgap, but is not an option for the finished script. I do have the option of arranging the ID-Strings in the data file differently (i.e. separate comment line as per columnheader, ...) - the only requirement is really that all line data should be in a single file.

b)我收到矩阵包含丢失或不确定的值"警告,这大大减慢了在屏幕上显示图像的速度.

b) I get TONS of "matrix contains missing or undefined value" warnings, which significantly slows down displaying the image on screen.

推荐答案

这不是gnuplot用于保存数据的方式.您的方法还存在其他问题,即,如果行具有不同数量的点等,则实际上没有矩阵.处理此类数据的gnuplot方法是用 two 空行,并在前面添加相应的标题:

This is not the way gnuplot uses to save data. Your approach has also other problems, i.e. you don't actually have a matrix if the rows have different number of points etc. The gnuplot way of handling such data would be to separate points belonging to different lines with two blank lines, and add the respective header before:

"ID01"
1
2
3
4
5


"ID02"
3
4
5
6
7
8
9


"ID03"
4
3
1
2
3
4

然后使用

set key autotitle columnheader left
plot for [i=0:2] 'MyFile.txt' using 0:1 index i with linespoints

或者,如果您希望使用更紧凑的表示形式,则可以将每一行保存在一列中.但是,您必须确保较短的列中都填满了空值.为此,应该使用例如逗号作为字段分隔符:

Alternatively, if you prefer a more compact representation, you can save each line in a column. But then you must make sure, that shorter columns are filled up with empty values. For that one should use e.g. comma as field separators:

"ID01","ID02","ID03"
1,3,4
2,4,3
3,5,1
4,6,2
5,7,3
 ,8,4
 ,9,

并使用

set key autotitle columnheader
set datafile separator ','
plot for [i=1:3] 'MyFile.csv' using 0:i with linespoints

这篇关于Gnuplot:将按行命名的数据绘制为成束的不同颜色和标题的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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