简体   繁体   English

使用不同颜色在 gnuplot 中绘制文件数据

[英]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

plot 'aaa.txt' every ::1::10 wp, 'aaa.txt' every ::11::20 wp, ...每 ::1::10 wp 绘制“aaa.txt”,每 ::11::20 wp 绘制“aaa.txt”,...

UPDATE更新

worked for me (well, except numbering should go from 0)为我工作(好吧,除了编号应该从 0 开始)

plot 'aaa.txt' every ::0::2 w p, 'aaa.txt' every ::3::5 w p

produced following graph产生如下图

在此处输入图片说明

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 个空行分开,则可以将特征indexfor loop

unset key
plot for [i=0:9] 'temp.txt' index i

在 10 项块中绘图

(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 个空行分隔每个数据块,则可以将特征indexfor 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM