Search code examples
gnuplotcolorboxlegend

Is it possible to use a function to calculate the real tic values based on the auto generated tic values in colorbox


I want to use a function to calculate the real tic value based its automatically generated value.

Here is the example:

set pm3d;
set pm3d map;
splot x*y;

It gives:

enter image description here

I want to use a function f(x)=x^2 to calculate the real tic values for the color box based on its automatically generated tic values: 100, 50, 0, -50, -100. Then the displayed values should be 10000, 2500, 0, 2500, 10000.

If it is difficult to deal with repeated 2500 and 10000, a solution to generate only half the legend values: 10000, 2500, 0 would also help.

Thanks.


Solution

  • You can replace the automatically generated cbtics with set cbtics add ...:

    set pm3d map
    f(x) = x**2
    set for [i=-100:100:50] cbtics add (sprintf('%d', f(i)) i)
    splot x*y
    

    enter image description here

    But this solution assumes, that you know the values of the automatic cbtics.