残念ながら、gnuplot は文字列全体にしか色を付けることができません"Number of Connections"
。frac
追加オプションを使用して色に影響を与えることができます。
ただし、ここにあなたが探していたものを達成する方法があります。ただし、以下で説明するように、いくつかの手動設定が必要です。
# define the location of your plot:
bm = 0.15
lm = 0.12
rm = 0.75
tm = 0.90
# letter spacing - play with this as needed:
STRDIST = 0.03
# set up the plot window:
set lmargin at screen lm
set rmargin at screen rm
set bmargin at screen bm
set tmargin at screen tm
# place the colorbar in a defined location:
set colorbox vertical user origin rm+0.1,0.15 size .05,tm-bm
# define your palette:
set palette model RGB defined ( \
0 '#F46D43',\
1 '#FDAE61',\
2 '#FEE08B',\
3 '#E6F598',\
4 '#ABDDA4',\
5 '#66C2A5' )
# your label
LABEL = "Number of Connections"
# the 'length' of LABEL, unfortunately counted manually:
LEN_LABEL = 21.0 # IMPORTANT, declare as float
# use a loop to individually place each char of the string on the plot:
do for [i=1:LEN_LABEL]{\
set label i LABEL[i:i] at screen 0.8,bm+((i-1.)*STRDIST) \
rotate by 90 textcolor palette frac i/LEN_LABEL\
}
# dummy function plot (so that there's something to see):
plot '+' using ($1):(sin($1)):(0.5*(1.0+sin($1))) w l lw 3 lc pal not
何が起こっている:
- プロットとカラーバーの位置を定義します。これにより、それらがどこにあるかが正確にわかり、「疑似」ラベルを正確に配置できます。
- 変数
STRDIST
は、個々の文字の間隔を空けるために使用されます。これは不器用ですが、要点はわかります。良い結果を得るためにそれで遊んでください。
- 残念ながら、gnuplot は文字列の長さを計算できないようです
LEN_LABEL
。
- -loop を使用してラベル文字列の各文字をプロットに配置し、追加オプション
do for
を使用してカラー パレットから色を割り当てます。は、カラー パレットで最も低く、「最も高い」色です。ここでは、ループ カウンターを利用して、パレットから等間隔の色を指定します。注:これが、整数またはすべてではなく浮動小数点数として宣言することが重要である理由ですが、最後の反復は. frac
frac 0.0
frac 1.0
LEN_LABEL
frac 0
plot '+' ...
コマンドはこちらのサイトから拝借。
上記の例をコピーして貼り付けると得られるプロットは次のようになります。

「ラベル」の開始点で遊んで、STRDIST
好みのラベルを生成/配置します。