【问题标题】:Filled contour plot with constant color between contour lines等高线之间具有恒定颜色的填充等高线图
【发布时间】:2014-01-25 11:23:05
【问题描述】:

我已经按照示例 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;

【问题讨论】:

    标签: plot gnuplot contour


    【解决方案1】:

    gnuplotset palette 选项带有maxcolors 设置。因此,对于您的情况,由于您有 12 行,您应该添加

    set palette maxcolors 12
    

    【讨论】:

    • 很好的解决方案!您只需要增加表面的采样次数,因为填充的轮廓不会被视为闭合多边形,而是缝合在一起。
    • @Christoph 是的,但是如果没有默认的 maxcolors 设置,您也会遇到这个问题,尽管不太明显。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多