Search code examples
colorsgnuplotsurfacecolormappalette

GNUPLOT splot color palete matching jetmap


I'm trying to reproduce the following image of rosenbrock function in gnuplot. Source Wikipedia.

See below

My understanding is that the image was created using JET colormap in Matlab/Matplotlib.

Here is my attempt in gnuplot. Macro MATLAB was sourced from here and Macro JET was sourced from here.

I think bringing the orange/yellow all the way down to 500 would be helpful. I'm not sure how to do this in gnuplot.

Also what would be the size to reproduce MATLAB like view?

reset session
set terminal wxt size 800,600 enhanced font 'Verdana,10' persist
set view 50,330
set isosample 30
set xlabel "x"
set ylabel "y"
set zlabel "f(x,y)" rotate
set pm3d


set macros
JET="define (0 0 0 0.5, 1./8 0 0 1, 3./8 0 1 1, 5./8 1 1 0, 7./8 1 0 0, 1 0.5 0 0)"

MATLAB = "defined (0  0.0 0.0 0.5, \
                   1  0.0 0.0 1.0, \
                   2  0.0 0.5 1.0, \
                   3  0.0 1.0 1.0, \
                   4  0.5 1.0 0.5, \
                   5  1.0 1.0 0.0, \
                   6  1.0 0.5 0.0, \
                   7  1.0 0.0 0.0, \
                   8  0.5 0.0 0.0 )"


set palette @JET

splot [x=-2:2] [y=-1:3] (1-x)**2+100*(y-x**2)**2 with pm3d notitle

set output

enter image description here


Solution

  • color mapping

    I think you will be most of the way there if you change the color mapping to log scale, and the rest of the way there if you adjust the lower bound on the palette range:

    # ... as above ...
    set log cb
    set cbrange [0.1 : *]
    unset mcbtics
    replot
    

    enter image description here

    bounding box

    gnuplot version 5.4:

    set wall x1  fillcolor "gray90"
    set wall y1  fillcolor "gray90"
    set wall z0  fillcolot "gray50"
    set xyplane at 0
    set border 127
    set grid vertical
    replot
    

    enter image description here