1

I have the following data:

ClockIndex       Max AvgStd  Avg      Num    Threshold
"ck1 (1.54 GHz)" 35  +16.30   11    11583    X
"ck2 (1.54 GHz)" 28  +16.66   12    10669    -
"ck3 (1.54 GHz)" 29  +14.47    9     8036    -
"ck4 (1.54 GHz)" 35  +18.99   12     5685    -
"ck5 (1.54 GHz)" 9   +6.04     3       11    -

I'm plotting columns 2, 3, 4 together in a points plot, one line per entry.

Using this code:

set xtics rotate
set xlabel ""
set ylabel "Levels"
set title "Levels - foo"
set key autotitle columnhead
set term png medium size 1200,600
set grid
set output "foo.png"
plot "foo.rpt" using 2:xticlabels(1) with points pt 13 ps 2 lt rgb "blue",\
"" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black

**Goal : If there's a "X" in the "Threshold" column, I want the "Max" point to be green, not blue.

I've tried using awk, but to no avail.

plot "< awk '{if($6 == \"X\") print }' foo.rpt" using 2:xticlabels(1) with points pt 13 ps 2 lt rgb "blue",\
"" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black"
"< awk '{if($6 == \"-\") print }' foo.rpt" using 2:xticlabels(1) with points pt 13 ps 2 lt rgb "green",\
"" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black"

I keep getting errors like:

"foo_gnuplot", line 11: warning: Skipping data file with no valid points

Any help would be greatly appreciated! Thanks much for taking a look! :)

2 Answers 2

2

You can do it like this:

plot "foo.rpt" using 2:xticlabels(1) with points pt 13 ps 2 lt rgb "blue",\
"" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black",\
"" using (strcol(6) eq "X" )?($2):(1/0):xticlabels(1) with points pt 13 ps 2 lt rgb "green"

(condition)?($plotThisValue):(1/0) is a common gnuplot technique for conditional plotting.

With that code the original point is overprinted with the green one. (If you want to remove the original (now hidden) blue point completely you can use the same technique in line one of your plot command.)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks much, I appreciate the help!
Hi havogt ... I forgot to add the 6th column in my data set. It worked after doing that. Thanks again!
0

Thanks much to havogt for the great answer! Here's what I ended up doing:

plot "foo.rpt" using 3:xticlabels(1) with points pt 13 ps 2 lt rgb "red",\
"" using 4:xticlabels(1) with points pt 13 ps 2 lt rgb "black",\
"" using (strcol(6) eq "X" )?($2):(1/0):xticlabels(1) with points pt 13 ps 2 lt rgb "green"
"" using (strcol(6) eq "-" )?($2):(1/0):xticlabels(1) with points pt 13 ps 2 lt rgb "blue"

Works great! Really appreciate the help!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.