我有一个Lat/Long向量,还有一个Z值,我需要在3d地图上显示,就像下图右边的那个我试过bar3,但它很复杂,因为它需要创建多个图形。
下面是一些代码:
S4 = shaperead(filename)
plot([S4.X],[S4.Y],'k'); % plots the map from a shapefile I loaded previously
XX = [-50 -51 ...];
YY = [-1 -2 ...];
ZZ = [ 2.2 3.2 ... ];
stem3(XX,YY,ZZ) % this is an option, but doesn't look good!! :(
我能怎么做吗?
谢谢!
最佳答案
因此,根据您想在哪里重新定位bar3
的能力,这里有一个简单的代码来完成这项工作。
对你来说不有趣的事情:
1-填充地图。
2.-设置灯光
3.-创建标签
2和3,很容易做到我不知道。
结果:
代码:
clear;clc;
S = shaperead('usastatehi.shp')
S(2)=[]; % Delete Alaska
S(10)=[];% Delete Haway
hold on
plot([S.X],[S.Y],'k'); % plots the map from a shapefile I loaded previously
% syntetic data
Y=[40,45,25];
X=[-100,-85,-80];
Z=[0.5 2.3 1.4];
cmap=colormap(strcat('parula(',num2str(length(Z)),')')); % Create a colormap. Change parula for anything you preffer
ar=abs(diff(ylim))/abs(diff(xlim));
for ii=1:length(X)
h=bar3(Z(ii));
Xaux=get(h,'Xdata');
Xaux=Xaux-1+X(ii);
set(h,'Xdata',Xaux)
Yaux=get(h,'Ydata');
Yaux=Yaux-1+Y(ii);
set(h,'Ydata',Yaux)
set(h,'FaceColor',cmap(ii,:));
end
axis off