相關的how to set label and line the same color in gnuplot標籤風格 - 但不完全一樣的...使用此代碼:設置可變文本顏色和色點在gnuplot的
set style line 1 linetype 1 linewidth 2 pointtype 3 linecolor rgb "aquamarine"
set style line 2 linetype 1 linewidth 2 pointtype 3 linecolor rgb "blue"
set style line 3 linetype 1 linewidth 2 pointtype 3 linecolor rgb "coral"
set xrange [0:3]
set yrange [0:3]
# function to get style index for coloring:
getCol(x) = (x==0)?1:((x==1)?2:3);
plot \
'-' using ($1+0.5):($2+0.5):(getCol($2)) with impulses \
lc variable notitle, \
"" using ($1+0.5):($2+0.5):(stringcolumn(2)):(getCol($2)) with labels \
textcolor variable point linestyle 1 pointtype 7 lc variable \
font ",6" offset character 1.0,character 1.0 notitle
0 0
1 1
1.5 1
2 2
e
0 0
1 1
1.5 1
2 2
e
...我得到這樣的輸出:
對於impulses
而言,它看起來像一切都很好 - 但對於labels
,該方法似乎有效 - 但它好像從不同索引中讀取顏色一樣!
那麼,如何使用相同的函數 - 如脈衝線,如何獲得點和標籤具有相同的變量顏色?這是在gnuplot 4.6 patchlevel 1 ...
這個問題已在新發布的4.6 patchlevel 4中修復。只需在繪圖之前添加'set style increment user'行,就可以得到預期的結果(與[我的回答](http:// stackoverflow.com/a/18368864/2604213))。 – Christoph