How to plot the 3D spherical histogram?
17 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a set of normal directions in 3D and I want to plot the histogram. But seem matlab only have 2D option. Is there any method I could have a plot like the attached figure? Or any other software could solve the problem?
Thanks a lot!
1 个评论
YONG TANG
2020-3-17
hi pei,
did you solve this problem?
recently, I'm also trying to plot some figures like what you mentioned.
could you give me some suggestions?
best,
yong
回答(1 个)
darova
2020-2-21
You can create it manually
clc,clear
v = rand(10,3)*2-1;
v0 = v(:,1)*0;
quiver3(v0,v0,v0,v(:,1),v(:,2),v(:,3),1)
axis equal
hold on
[ph,th,r] = cart2sph(v(:,1),v(:,2),v(:,3));
[X,Y,Z] = deal(zeros(4));
for i = 1:size(v,1)
ph1 = ph(i) + pi/180*[-1 1 -1 1]*5; % azimuth phi
th1 = th(i) + pi/180*[1 1 -1 -1]*5; % elevation theta
[x1,y1,z1] = sph2cart(ph1,th1,r(i));
X([6 7 10 11]) = x1;
Y([6 7 10 11]) = y1;
Z([6 7 10 11]) = z1;
surf(X,Y,Z,'facecolor',rand(1,3))
pause(0.5)
end
hold off
alpha(0.5)
1 个评论
darova
2020-2-21
Set color according to radius
cmap = jet(50);
for i = 1:size(v,1)
%% ...
ix = round(r(i)/max(r)*49)+1;
surf(X,Y,Z,'facecolor',cmap(ix,:))
pause(0.5)
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!