使用matlab绘制等值线图的问题

问题描述 投票:0回答:1

如何用matlab绘制不规则图形的等值线图?我的代码如下:

figure(11)
[xq,yq] = meshgrid(0:0.1:225, 0:0.1:40);
vq = griddata(gcoord(:,1),gcoord(:,2),uw,xq,yq);
contourf(xq,yq,vq,'ShowText','on','LineStyle','-')
xlabel('Distance(m)','FontName','Times New Roman','FontSize',12,'FontWeight','bold');
ylabel('Elevation(m)','FontName','Times New Roman','FontSize',12,'FontWeight','bold');
set(gca,'FontName','Times New Roman','FontSize',12,'FontWeight','bold');
colorbar
colormap jet
hr=colorbar;
set(get(hr,'Title'),'string','kPa');
% set(hr,'Position',[0.875129310344827 0.17 0.0149999999999999 0.68],'box','off');
box off

gcoord
是包含 x-y 坐标的数据。

我想要得到如下形状的等高线图:

enter image description here

但是代码的结果是这样的:

enter image description here

我应该如何修改我的代码?

matlab data-analysis matlab-figure contour
1个回答
0
投票

正如 John BG 评论的那样,如果没有 gcoord 的变量数据,我们无法将您的数据复制到测试解决方案。我对 stackoverflow 太陌生,无法发表评论,所以我需要将此作为答案提交。

我对此的第一直觉是尝试使用 xlim 和 xtick 值来控制绘图。我在您发布的示例中看到它有几个特定的 xtick 值(以 20 为增量),而您的绘图没有。我会查看有关如何实现这些的 MATLAB 文档。

xticks 上的 MATLAB 帮助

© www.soinside.com 2019 - 2024. All rights reserved.