简体   繁体   中英

Gnuplot using odd number of lines and even number in the same graph from a same file

I have a file which has this values (fio mixed read write result):

1191, 3987, 0, 0, 0
1191, 11781, 1, 0, 0
2193, 4006, 0, 0, 0
2193, 12431, 1, 0, 0
3195, 3698, 0, 0, 0
3195, 11680, 1, 0, 0
4196, 3897, 0, 0, 0
4196, 11407, 1, 0, 0
5198, 3845, 0, 0, 0

I want to draw a lines connected together the even numbered lines separately, and the odd numbered separately.

I'd like to use something like this, but this doesn't work:

plot "<(sed -n 'p;n' 8k-mix_iops.4.log)" using $1/1000):2 title "25-75 write" with lines, "<(sed -n 'n;p' 8k-mix_iops.4.log" using ($1/1000):2 title "25-75 read" with lines

Or I could use somehow the every command but how can I define every second line but start from the 1st line or start from the 2nd line?

plot "8k-mix_iops.4.log" every 2 using ($1/1000):($2) title "25-75 write" with lines, "8k-mix_iops.4.log" every 1 using ($1/1000):($2) title "25-75 read" with lines

Every " ( you need to close in proper order.

plot "<(sed -n 'p;n' file)" using ($1/1000):($2) title "25-75 write" with lines, "<(sed -n 'n;p' file)" using ($1/1000):($2) title "25-75 read" with lines;

Draws for me:

在此处输入图片说明

I don't see any reason to use sed. In the gnuplot console type help every to get an understanding what every does.

Code:

### plot odd and even rows
reset session
set datafile separator comma

$Data <<EOD
1191, 3987, 0, 0, 0
1191, 11781, 1, 0, 0
2193, 4006, 0, 0, 0
2193, 12431, 1, 0, 0
3195, 3698, 0, 0, 0
3195, 11680, 1, 0, 0
4196, 3897, 0, 0, 0
4196, 11407, 1, 0, 0
5198, 3845, 0, 0, 0
EOD

plot $Data u ($1/1000):($2) every 2 w l title "25-75 write", \
     '' u ($1/1000):($2) every 2::1 w l title "25-75 read"
### end of code

Result:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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