Filled contour chart with a constant color between the contour lines

I followed an example here to create a filled outline graph using gnuplot. Gnuplot commands and output:

reset
f(x,y)=sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x)
set xrange [-5:5]
set yrange [-5:5]
set isosample 250, 250
set table 'test.dat'
splot f(x,y)
unset table

set contour base
set cntrparam level incremental -3, 0.5, 3
unset surface
set table 'cont.dat'
splot f(x,y)
unset table

reset
set xrange [-5:5]
set yrange [-5:5]
unset key
set palette rgbformulae 33,13,10
p 'test.dat' with image, 'cont.dat' w l lt -1 lw 1.5

Filled contour plot generated using gnuplot.

This method generates a very smooth filled outline graph. How to change this method so that the color between the contour lines is constant? For example, I would like it to look the same as the output of this MATLAB script:

clc; clear all; close all;

Nx = 250;
Ny = 250;
x = linspace(-5,5,Nx);
y = linspace(-5,5,Ny);
[X,Y] = meshgrid(x,y);

f = sin(1.3*X).*cos(.9*Y) + cos(.8*X).*sin(1.9*Y) + cos(Y.*.2.*X);

levels = -3:0.5:3;
figure;
contourf(X,Y,f,levels);
colorbar;

Filled contour plot generated using MATLAB.

+4
source share
1 answer

gnuplot set paletteoption comes with customization maxcolors. Therefore, for your case, since you have 12 lines, you should add

set palette maxcolors 12
+5
source

All Articles