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?
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.
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: