2015-07-24 3 views
1

J'ai les données suivantes:gnuplot - couleurs conditionnelles dans un terrain de points

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 - 

Je complotant les colonnes 2, 3, 4 ensemble dans un terrain de points, une ligne par entrée.

En utilisant ce 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 

** But: S'il y a un "X" dans la colonne "Seuil", je veux le point d'être vert "Max", pas bleu.

J'ai essayé d'utiliser awk, mais en vain.

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" 

Je continue de recevoir des erreurs comme:

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

Toute aide serait grandement appréciée! Merci beaucoup d'avoir jeté un coup d'oeil! :)

Répondre

1

Vous pouvez le faire comme ceci:

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) est une technique gnuplot commune pour le traçage conditionnel.

Avec ce code, le point d'origine est surimprimé avec le point vert. (Si vous voulez supprimer complètement le point bleu d'origine (maintenant masqué), vous pouvez utiliser la même technique dans la première ligne de votre commande plot.)

+0

Merci beaucoup, j'apprécie l'aide! – user5150183

+0

Avec les mêmes données et la même commande plot? – havogt

+0

Et ça a bien fonctionné, merci beaucoup! – user5150183

0

Merci beaucoup d'avoir vanté la bonne réponse! Voici ce que j'ai fini par faire:

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" 

Fonctionne bien! Vraiment apprécier l'aide!