[英]Plot file data in gnuplot using different colors
Plotting data of file data.txt from line 1 to 10 in some color say red and next 10 to 20 with other similarly 20 to 30 with different color till 100th row从第 1 行到第 10 行以某种颜色绘制文件 data.txt 的数据,例如红色,接下来的 10 到 20 与其他类似的 20 到 30 不同颜色,直到第 100 行
data.txt file is something like this: data.txt 文件是这样的:
1 1
2 2
3 3
4 4
5 5
6 6
..
..
..
10 10
1 2
3 4
1 1
..
..
..
..
.
.
.
.
90 90
91 91
..
..
..
100 100
If you can structure your data-file to separate every data block
with 2 empty lines, you can use feature index
with a for loop
:如果您可以构建数据文件以将每个
data block
与 2 个空行分开,则可以将特征index
与for loop
:
unset key
plot for [i=0:9] 'temp.txt' index i
(my datafile is 1-10 in every block (1-10, 11-20...), structured with 2-2 empty lines) (我的数据文件在每个块(1-10、11-20 ...)中为 1-10,由 2-2 行空行构成)
If you can't structure your data-file (our you are just lazy ;-) ) you can use only the for loop
:如果您无法构建数据文件(我们的您只是懒惰;-)),则只能使用
for loop
:
plot for [i=0:9] 'temp2.txt' every ::i*10::i*10+9
(my datafile is 1-10 in every block (1-10, 11-20...) without empty lines) (我的数据文件在每个块(1-10、11-20 ...)中为 1-10,没有空行)
EXTENSION (according to Karl )扩展(根据卡尔)
If you can structure your data-file to separate every data block with 1 empty lines, you can use feature index
with a for loop
如果您可以构建数据文件以用 1 个空行分隔每个数据块,则可以将特征
index
与for loop
plot for [i=0:9] 'temp3.txt' every :::i::i
(my datafile is 1-10 in every block (1-10, 11-20...), structured with 1-1 empty lines) (我的数据文件在每个块(1-10、11-20...)中为 1-10,由 1-1 个空行构成)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.