每个数据集有不同的颜色 [英] Different color per dataset

查看:155
本文介绍了每个数据集有不同的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过2天的试验和错误,我在这里请求帮助,因为我完全失去了gnuplot。
我想要的是用不同的颜色显示几个数据集,命名列。
以下是结果:





第一个问题:图表上的线条颜色不同,但标题颜色相同。
第二个问题:如果我用列(-2)替换plotline后面的idx(即:

  datafile索引idx使用packetid:'mapping_dsn':( 0):mapping_length:(列(-2))与向量填充头大小屏幕0.008,145 lc palette z标题sprintf(数据集%d 2))

我有这个输出





在我看来idx和列(-2)应该是等效的?
这是gnuplot脚本的缩写版本(我相信最关键的部分):

  stats datafile every :: 2 
set palette maxcolors 3
set palette defined(0'green',\
1'red',\
2'blue ')

set key autotitle columnhead
set cbrange [0:STATS_blocks-1]

绘制[idx = 0:STATS_blocks-1] \
datafile index idx usingpacketid:'mapping_dsn':( 0):mapping_length:( idx)with vectors fill head size screen 0.008,145 lc palette z title sprintf(dataset%d,idx)

我的数据格式包含2个数据集,看起来像这样(我删除了一些数据, :

  packetid | time_delta | ip4src | ip4dst | ip6src | ip6dst | mptcpstream | tcpstream | subtype | tcpseq | mapping_ssn | mapping_length | mapping_dsn | ssn_to_dsn | dataack 
2 | 0.000000000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 0 | 0 |||||
5 | 0.000067000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 2 | 1 | 1 | 20 | 0 ||
6 | 0.000125000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 2 | 21 | 21 | 20 | 20 ||
8 | 0.000064000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 2 | 41 | 41 | 20 | 40 ||
9 | 0.000125000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 2 | 61 | 61 | 20 | 60 ||

packetid | time_delta | ip4src | ip4dst | ip6src | ip6dst | mptcpstream | tcpstream | subtype | tcpseq | mapping_ssn | mapping_length | mapping_dsn | ssn_to_dsn | dataack
2 | 0.000000000 | 192.168.1.1 | 192.168 .1.2 ||| 0 | 0 | 0 | 0 |||||
5 | 0.000067000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 2 | 1 | 1 | 20 | 0 ||
6 | 0.000125000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 2 | 21 | 21 | 20 | 20 ||
8 | 0.000064000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 2 | 41 | 41 | 20 | 40 ||
9 | 0.000125000 | 192.168.1.1 | 192.168.1.2 ||| 0 | 0 | 2 | 61 | 61 | 20 | 60 ||

在信息后编辑:christophe:根据你的一个dvice(linetype 0不存在,所以我reindexed一点):

  set linetype 1 lw 3 pt 3 lc rgbred
set linetype 2 lw 3 pt 3 lc rgbgreen

...数据文件索引idx使用packetid:'mapping_dsn':( 0):mapping_length :(idx + 1)with vector fill head size screen 0.008,145 lc variable title sprintf(Mappings from dataset%d,idx)

标题箭头全部为黑色(而不是红色和绿色):
c $ c> c $ c> linecolor调色板的问题(以及与 linecolor变量)方法是,linecolor可以变化为一个单一的情节。



要获得正确的键,必须使用 lc idx



使用packetid:mapping_dsn:( 0):mapping_length用向量填充头大小屏幕0.008,145 lc idx + 1标题为[idx = 0:STATS_blocks-1] \
数据文件索引idx sprintf(dataset%d,idx)

关于 vs idx :使用列(-2) c>使用语句无法正常工作。我认为这样做时应该给出错误。


After 2 days of trials and errors, I ask for help here since I am totally lost with gnuplot. All I want is to display a few datasets in different colors, with named columns. Here is the result:

First problem: lines on the graph have different colors but in the title colors are the same. 2nd problem: If I replace "idx" after the plotline by column(-2) (ie:

datafile index idx using "packetid":'mapping_dsn':(0):"mapping_length":(column(-2)) with vectors filled head size screen 0.008,145 lc palette z title sprintf("dataset %d", column(-2)) 

I've got this output

In my opinion idx and column(-2) should be equivalent? Here is a shortened version of the gnuplot script (most critical parts I believe):

stats datafile every ::2
set palette maxcolors 3
set palette defined ( 0 'green', \
                      1 'red', \
                      2 'blue' )

set key autotitle columnhead
set cbrange[0:STATS_blocks-1]

plot for [idx=0:STATS_blocks-1] \
    datafile index idx using "packetid":'mapping_dsn':(0):"mapping_length":(idx) with vectors filled head size screen 0.008,145 lc palette z title sprintf("dataset %d", idx)

My data format consists of 2 datasets and looks like this (I've removed some data to make it shorter):

packetid|time_delta|ip4src|ip4dst|ip6src|ip6dst|mptcpstream|tcpstream|subtype|tcpseq|mapping_ssn|mapping_length|mapping_dsn|ssn_to_dsn|dataack
2|0.000000000|192.168.1.1|192.168.1.2|||0|0|0|0|||||
5|0.000067000|192.168.1.1|192.168.1.2|||0|0|2|1|1|20|0||
6|0.000125000|192.168.1.1|192.168.1.2|||0|0|2|21|21|20|20||
8|0.000064000|192.168.1.1|192.168.1.2|||0|0|2|41|41|20|40||
9|0.000125000|192.168.1.1|192.168.1.2|||0|0|2|61|61|20|60||

packetid|time_delta|ip4src|ip4dst|ip6src|ip6dst|mptcpstream|tcpstream|subtype|tcpseq|mapping_ssn|mapping_length|mapping_dsn|ssn_to_dsn|dataack
2|0.000000000|192.168.1.1|192.168.1.2|||0|0|0|0|||||
5|0.000067000|192.168.1.1|192.168.1.2|||0|0|2|1|1|20|0||
6|0.000125000|192.168.1.1|192.168.1.2|||0|0|2|21|21|20|20||
8|0.000064000|192.168.1.1|192.168.1.2|||0|0|2|41|41|20|40||
9|0.000125000|192.168.1.1|192.168.1.2|||0|0|2|61|61|20|60||

EDIT after message from christophe: I still have a problem though after modifying according to your a dvice (linetype 0 does not exist so I reindexed a bit):

set linetype 1 lw 3 pt 3 lc rgb "red"
set linetype 2 lw 3 pt 3 lc rgb "green"

... datafile index idx using "packetid":'mapping_dsn':(0):"mapping_length":(idx+1) with vectors filled head size screen 0.008,145 lc variable title sprintf("Mappings from dataset %d", idx)

Title arrows are all in black (instead of red and green):

解决方案

The problem with the linecolor palette (and also with linecolor variable) approach is, that the linecolor can vary for a single plot. Gnuplot doesn't consider the special case when the color specification is constant for all points.

To have the correct keys, you must use lc idx with the loop index idx:

plot for [idx=0:STATS_blocks-1] \
datafile index idx using "packetid":'mapping_dsn':(0):"mapping_length" with vectors filled head size screen 0.008,145 lc idx+1 title sprintf("dataset %d", idx)

Concerning column(-2) vs idx: Using column(-2) outside of the using statement doesn't work properly. I my opinion it should give an error when doing so.

这篇关于每个数据集有不同的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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