3

Some what related to previous question

I would like to take the default (pm3d default) colour palette of gnuplot and place a white value at X and have anything >=X as white but the rest(<X) still evently distributed with the default value.

Say for example I have values between 0 and 100. I am only interested in values 0 to 30 so I do the following:

set cbrange [0:30]

Now values are evenly distributed between 0 and 30 with the default colour palette, however values 30.001 to 100 are all yellow. I would like to place a white block at the top of my colour palette, say something like this on the colour bar

0:30 evenly distribute with default palette 30:31 white

and in the actual plot, have values >=30 as white.

I know I can set defined values, but I can't seem to combine the default rgbformula 7,5,15 and a defined point of 30=white.

Any thoughts?

Community
  • 1
  • 1
dogAwakeCat
  • 311
  • 2
  • 15

1 Answers1

4

You can define your own, function-based palette with set palette functions. Typing show palette rgbformulae shows you the definitions of the functions used for the default palette (7,5,15):

gnuplot> show palette rgbformulae
      * there are 37 available rgb color mapping formulae:
         0: 0               1: 0.5             2: 1              
         3: x               4: x^2             5: x^3            
         6: x^4             7: sqrt(x)         8: sqrt(sqrt(x))  
         9: sin(90x)       10: cos(90x)       11: |x-0.5|        
        12: (2x-1)^2       13: sin(180x)      14: |cos(180x)|    
        15: sin(360x)      16: cos(360x)      17: |sin(360x)| 
        ...

So you can define your own functions for red, green and blue which give white at one end of the palette:

r(x) = sqrt(x)
g(x) = x**3
b(x) = (x == 1 ? 1 : sin(2*pi*x))
set palette functions r(gray),g(gray),b(gray)

For demonstration, here is a full example script, where all values above -10 are white:

r(x) = sqrt(x)
g(x) = x**3
b(x) = (x == 1 ? 1 : sin(2*pi*x))
set palette functions r(gray),g(gray),b(gray)
set isosamples 100
set pm3d map
set cbrange [-200:-10]
set cbtics -200,40
set cbtics add ('> -10' -10)
splot -x**2 - y**2 notitle

Output with 4.6.5 is:

enter image description here

Christoph
  • 47,569
  • 8
  • 87
  • 187
  • Great. A couple of bits I don't get though. Why does one pass `gray` instead of the value, such as `r(gray$1)` if loading from a file? Also, in `b(x)` 1 is the max value of `cbrange` correct? I was hoping I could set it to a value `X` and then have the actual colourbar plot to `X+10` for example so there is an actual white block at the top of the colour bar. – dogAwakeCat Sep 24 '14 at 00:24
  • For example, I was hoping it was possible to have a colorbar plotted like [this](http://imgur.com/F4giDLf) – dogAwakeCat Sep 24 '14 at 00:31
  • Ok i've got it: replace all so have ternary. `r(x) = (x >= 0.9 ? 1 : sqrt(x))`, `g(x) = (x >= 0.9 ? 1 : x**3))` and `b(x) = (x >= 0.9 ? 1 : sin(2*pi*x))`. Thanks for your help – dogAwakeCat Sep 24 '14 at 02:50
  • When loading data from a file some column expression, given with `using` determines the colors. These values are then mapped to the range `[0,1]` which represents the whole color space. The variable `gray` represents the relative position of a data point in this normalized color range... or something like this :) – Christoph Sep 24 '14 at 06:44