gnuplot palette, default and defined

狂风中的少年 提交于 2019-12-13 14:09:56

问题


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?


回答1:


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:



来源:https://stackoverflow.com/questions/25966773/gnuplot-palette-default-and-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!