Reputation: 2061
I'd like to plot simple 2D point graph with dots either red or green, where color is determined by third, string column. This one doesn't compile:
plot "data.txt" using 1:2:3 with points lc rgbcolor (stringcolumn(4) eq "B" ? "green" : "red")
complaining that :
stringcolumn() called from invalid context
Data looks like this:
1,2,"A"
2,3,"A"
3,1,"B"
4,2,"A"
How to do this?
Upvotes: 1
Views: 469
Reputation: 12255
You can do this by assigning a linetype number to each colour, then evaluating column 3 into one of these numbers. Eg:
set linetype 1 lc 'green'
set linetype 2 lc 'red'
plot "data.txt" using 1:2:(stringcolumn(3) eq "B"?1:2) with points lc variable
Note, your data columns must be separated by whitespace not commas.
Upvotes: 2