Unfortunately, gnuplot can only color the entire string "Number of Connections"
. You can influence the color using the additional frac
option.
However, here's a way to achieve what you were looking for. It involves some manual settings, though, as I'll explain below:
# 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
What is going on:
- Define the location of your plot and of the colorbar: That way you will know exactly where they are and can place a "pseudo"-label accurately.
- The variable
STRDIST
is used to space the individual letters. This is clumsy, but you get the gist. Play with it to achieve good results. - Unfortunately, it seems that gnuplot cannot compute the length of a string, so I hard-wired it,
LEN_LABEL
. - Use a
do for
-loop to place each letter of the label string on the plot, assigning a color from the color palette using the additionalfrac
option.frac 0.0
is the lowest andfrac 1.0
the "highest" color on the color palette. Here, we exploit the loop-counter to give evenly spaced colors from the palette. Note: This is why it is important to declareLEN_LABEL
as a float, not integer or everything but the last iteration will result infrac 0
. - The
plot '+' ...
command is borrowed from this site.
The plot you get when you copy/paste the above example looks like this:
Play with the starting point of the "label" as well as the STRDIST
to generate/place a label of your liking.