Dear all,
I'd like to plot a set of data points as impulses, colored according to the
value in the 3rd column.
Here is a short example:
reset
set xrange [0:5]
set yrange [0:1]
plot '-' u 1:2:3 w imp lc var
1 1 1 red
2 1 2 green
3 1 1 red
4 1 3 blue
e
What I get are four lines, two red ones at 1 and 3, a green one at 2 and a blue
one at 4.
So far so good.
Now I'd like to get a key that shows each used color, labeled with the
corresponding string value in column 4. So far it shows just a single black line.
I know, I could do something like
plot 'data.file' u 1:($3=1 ? $2 : 1/0) t "red", '' u 1:($3=2 ? $2 : 1/0) t
"green", '' u 1:($3=2 ? $2 : 1/0) t "blue"
However, the actual data set is very large and generated on the fly using a awk
script. And there are a total of 12 different instances in column 4. Using a
solution like the one above would mean to run the awk script 12 times. Beside
that don't like to compare column 3 to hard coded values (the number of
instances might change in the future), this is not efficient enough, as the awk
script takes quite some time to generate the data set.
Any ideas on how to create the key from variable line colors directly?
Preferably, using a single call to my awk script?
Thank you,
Andreas
|