怎么画出这种图,颜色代表数据大小,变量有x、y两个
技术分享
发布于 2025-07-22 14:52:59
查看 3过去315天
问题现象
咨询画出这种图,颜色代表数据大小,变量有x、y两个(Matlab用m_pcolor函数)

解决方法
通过类似下方的代码可以画出类似的图
示例:
x = -10:1:10;
y = -10:1:10;
z = zeros(21, 21)
for xx = x
for yy = y
z[xx+11, yy+11] = 100 - xx^2 - yy^2
end
end
figure()
s = pcolor(x, y, z)
s.set_edgecolor("flat")
colorbar(gca(), s)
colormap(s, "jet")
xlabel("X");
ylabel("Y");

所属专栏:Syslab基础平台
产品信息:Syslab科学计算环境