Gnuplot的起始位置为x [英] Gnuplot start to end position as x

查看:44
本文介绍了Gnuplot的起始位置为x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据文件test.tsv,它由三列组成:

字母开始结束

a 15 20

a 40 60

b 124171

b 237316

我将y轴设置为代表a和b,如何使线条覆盖物从头到尾?

解决方案

在更一般的情况下,您可以执行以下操作,该操作类似于

I have a data file test.tsv which consists of three columns:

letter start end

a 15 20

a 40 60

b 124 171

b 237 316

I set y axis to represent the a and b, How can I get lines cover start to end?

解决方案

In a more general case you could do the following which is similar to the solution here.

  1. Create a list of unique keys and use those as the y-axis tics/labels.
  2. Define a lookup function and plot the data accordingly.

You can use the plotting style with vectors but if you want thicker bars instead of lines, I would use the plotting style with boxxyerror because thicker lines also extend in line direction.

Code:

### Schedule plot
reset session

$Data <<EOD
# category  start    end
"a task"  15   20
"b task"  40   60
"c task"  124 171
"d task"  237 316
"c task"   30  35
"a task"  111 197
"d task"   95 103
"b task"   80  93
"special"  10 100
EOD

# create list of unique keys
KeyList = ''
set table $Dummy
    plot $Data u (Key='"'.strcol(1).'"', strstrt(KeyList,Key) ? \
    NaN : KeyList=KeyList.Key." ") w table
unset table

# define function for lookup
Lookup(s) = (Index = NaN, sum [i=1:words(KeyList)] \
    (Index = s eq word(KeyList,i) ? i : Index,0), Index)

set yrange [0.5:words(KeyList)+0.5]

plot $Data u 2:(Index=Lookup(strcol(1))):($3-$2):(0):(Index): \
     ytic(word(KeyList,Index)) w vector nohead lw 4 lc var notitle
### end of code

Result:

这篇关于Gnuplot的起始位置为x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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