4
我遵循示例here使用gnuplot生成填充等高线图。的gnuplot的命令和输出是:等高线之间的颜色不变的填充轮廓图
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
此方法生成非常平滑的填充等高线图。如何修改此方法以使轮廓线之间的颜色保持不变?例如,我想为它类似于此MATLAB脚本的输出:
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;
好的解决方案!您只需要增加表面的采样数量,因为填充后的轮廓不会被视为封闭的多边形,而是被拼接在一起。 – Christoph
@Christoph是的,但你也有这个问题没有默认的maxcolors设置,虽然不太明显。 – Bernhard