在Matlab中的地图上绘制3d条形图 [英] Plot 3d bars on a map in Matlab
问题描述
这里是一些代码:
S4 = shaperead(filename)
图([S4.X],[S4.Y],'k'); %从以前加载的shapefile中绘制地图
XX = [-50 -51 ...];
YY = [-1 -2 ...];
ZZ = [2.2 3.2 ...];
stem3(XX,YY,ZZ)%这是一个选项,但看起来不太好! (
有什么想法可以怎么做?
thx!
因此,根据您在这里所需的任何地方重新定位 bar3
的能力,有一个简单的代码来完成工作
对于您而言,您可能会感兴趣的事情:
1-填写地图
2. - 设置ligth
3.创建标签
2和3,可以轻松完成1我不知道。 p>
结果:
CODE:
clear; clc;
S = shaperead('usastatehi.shp')
S(2)= [];%删除阿拉斯加
S(10)= [];%删除Haway
保持
图([SX],[SY],'k');%从shapefile I绘制地图加载前
%合成数据
Y = [40,45,25];
X = [ - 100,-85,-80];
Z = [0.5 2.3 1.4];
cmap = colormap(strcat('parula(',num2str(length(Z)),')')); %创建色彩图。更改parula任何你预付
ar = abs(diff(ylim))/ abs(diff(xlim));
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
I have a Lat/Long vector, and another with Z values that I need to show on a 3d map just like the one on the right of the following figure. I tried bar3 but it's combuersome as it requires creating multiple graphs.
here's some code:
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!! :(
Any ideas on how can I do this? thx!
So based in the ability of relocating bar3
wherever you want here there is a simple code that does the job.
Things that does not and may be interesting for you:
1- Fill the map. 2.-Set the ligth 3.-Create the labels
2 and 3, they can be easily done. 1 I dont know.
Result:
CODE:
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
这篇关于在Matlab中的地图上绘制3d条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!