Search code examples
gnuplotscale

How can I modify the scale in gnuplot to an arbitrary function?


I'd like to have a logarithmic color bar like

1, 10^-2, 10^-4, 10^-6, 0 (or +-10^-8), -10^-6, -10^-4, -10^-2,

all with the same spacing in between

but I couldn't find any commands for intenser modification of the scale.

Please send help :)


Solution

  • You can set arbitrary tic labels. Check help cbtics or help xtics. That's what you have asked for, however, I assume you also want to plot some data. What do you want to plot? A map, some function? How does your data look like? Additionally, you have to define some mapping function for your data.

    Addition:

    This would be a possible (discontinuous) mapping function for mapping your values from [-1:-1e-8] to [-1:0] and from [+1e-8:1] to [0:1], and values with abs(value)<1e-8 to NaN.

    f(x) = abs(x)<1e-8 ? NaN : sgn(x)*(1+log10(abs(x))/8)
    

    Code:

    reset session
    
    set xrange[1e-10:1]
    set logscale xy
    set grid x,y
    
    set cbrange[-1:1]
    
    set cbtics("-1" -1, "-10^{-2}" -0.75, "-10^{-4}" -0.5, "-10^{-6}" -0.25, "0" 0, \
                "1"  1,  "10^{-2}"  0.75,  "10^{-4}"  0.5,  "10^{-6}"  0.25)
    
    plot x lc palette
    

    Result:

    enter image description here