1

is there any option in gnuplot to assign the threshold values of a discrete colormap manually? I have already fixed the range, but the color range is automatically adjusted linearly between them.

set cbrange [1.5:5]
set palette maxcolors 4
set palette defined ( 0 '#000fff',\
                    1 '#ee0000',\
                    2 '#90ff70',\
                    3 '#000000')

Say, I want the first color from [1.5,2], the second from [2,2.1], ... as an example.

Thanks

etkm
  • 13
  • 3

1 Answers1

0

It depends on what you want to plot. Find two attempts below. The first one is using a function for the color. This has the advantage that you can use also transparent color. I guess transparent color in a palette is not (yet) possible (see Gnuplot: transparency of data points when using palette). The second approach uses a palette and redefines datapoints outside the color range as NaN. The following example might be a starting point.

Code:

### palette with defined not equidistant color ranges
reset session

# create some test data
set isosamples 100
set samples 100
set table $Data
    plot '++' u 1:2:(abs($1*$2)/5+1.4) w table
unset table

myColor(n) = n<1.5 ? 0xff123456 : \
             n<2.0 ? 0x000fff : \
             n<2.1 ? 0xee0000 : \
             n<3.5 ? 0x90ff70 : \
             n<5.0 ? 0x000000 : 0xff123456

set cbrange [1.5:5]
set palette defined (1.5 "#000fff", 2.0 "#000fff", \
                     2.0 "#ee0000", 2.1 "#ee0000", \
                     2.1 "#90ff70", 3.5 "#90ff70", \
                     3.5 "#000000", 5.0 "#000000")

set size square
set multiplot layout 1,2

    plot $Data u 1:2:(myColor($3)) w p pt 5 ps 0.4 lc rgb var notitle

    plot $Data u 1:2:($3<1.5 || $3>5.0 ? NaN : $3) w image notitle

unset multiplot
### end of code

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72