Matlab中的surf()仅显示两种颜色,而不是多种颜色
我使用以下代码行进行绘图:Matlab中的surf()仅显示两种颜色,而不是多种颜色,matlab,colors,plot,surf,variations,Matlab,Colors,Plot,Surf,Variations,我使用以下代码行进行绘图: nthTheta=1; gammaSurf=reshape(gamma(:,nthTheta,:),size(gamma,1),size(gamma,3)); figure [spatial_lag,temporal_lag]=meshgrid(distance,4:4:12); surf(gammaSurf,spatial_lag',temporal_lag') colorbar xlabel('Spatial Lag','Fontweight','Bold') y
nthTheta=1;
gammaSurf=reshape(gamma(:,nthTheta,:),size(gamma,1),size(gamma,3));
figure
[spatial_lag,temporal_lag]=meshgrid(distance,4:4:12);
surf(gammaSurf,spatial_lag',temporal_lag')
colorbar
xlabel('Spatial Lag','Fontweight','Bold')
ylabel('Temporal Lag','Fontweight','Bold')
zlabel('\gamma (h,t)','Fontweight','Bold')
title('Spatiotemporal Empirical Variogram','Fontweight','Bold')
gammaSurf
矩阵具有以下值,表明其值正在变化:
我得到了以下只有两种颜色的图,而不是多种颜色的变化:
我是否做错了什么,因为我没有得到我所期望的具有多种颜色变化的绘图?谢谢 设置要插值的对象:
shading(gca,'interp');
我们应该做到这一点
实际上,看起来你的surf
的参数顺序不对。如果希望z轴应用于gammasurf值,则需要将其作为第三个参数
surf(spatial_lag',temporal_lag',gammasurf);
最后一个建议是:如果您确实想让gammasurf
成为x值,但您想让它们成为定义颜色的因素,请将其用作第四个参数(C
):
现在,曲面将像图像中一样定向,但颜色随x值而不是z值变化。谢谢tPearce!!你是对的,我得到的参数顺序错误,也就是说,
gammaSurf
应该是第三个参数。
surf(gammasurf,spatial_lag',temporal_lag',gammasurf);