how to overlay multiple images using scatter3?

5 ビュー (過去 30 日間)
Woo-Seok Lee
Woo-Seok Lee 2018 年 9 月 13 日
編集済み: jonas 2018 年 9 月 13 日
I want to plot two ellipsoids.
%making axes
Sx=1; Sy=1; Sz=1; Nx=50; Ny=50; Nz=50; dx= Sx/Nx; dy=Sy/Ny; dz=Sz/Nz;
xa=[0:Nx-1]*dx;
ya=[0:Ny-1]*dy;
za=[0:Nz-1]*dz;
xa=xa-mean(xa);
ya=ya-mean(ya);
za=za-mean(za);
[X,Y,Z]=meshgrid(xa,ya,za);
%bigger ellipsoid
rx=0.5;
ry=0.35;
rz=0.2;
A=zeros(length(xa),length(ya),length(za));
A(((X/rx).^2+(Y/ry).^2+(Z/rz).^2)<=1)=1;
A(((X/rx).^2+(Y/ry).^2+(Z/rz).^2)>1)=NaN;
%plotting by scatter3
figure, scatter3(X(:),Y(:),Z(:),[],A(:)), colormap cool, axis equal, axis tight, grid on;
hold on;
%smaller ellipsoid with half radius
rx=rx/2;
ry=ry/2;
rz=rz/2;
A2=zeros(length(xa),length(ya),length(za));
A2(((X/rx).^2+(Y/ry).^2+(Z/rz).^2)<=1)=0;
A2(((X/rx).^2+(Y/ry).^2+(Z/rz).^2)>1)=NaN;
%plotting smaller one by scatter3
scatter3(X(:),Y(:),Z(:),[],A2(:));
hold off;
But the the latter scatter3 function doesn't make any change. When I only run the code:
scatter3(X(:),Y(:),Z(:),[],A2(:));
then smaller ellipsoid is shown. When the whole code run, only the bigger one is shown. What's the problem?

採用された回答

jonas
jonas 2018 年 9 月 13 日
編集済み: jonas 2018 年 9 月 13 日
This is a continuation of this question.
As I just stated in that thread, the reason is due to the smaller ellipsoid being hidden by the larger one. You can increase the transparency of the larger one to see both.
First save the handles when you plot:
h1=scatter3(X(:),Y(:),Z(:),[],A(:))
h2=scatter3(X(:),Y(:),Z(:),[],A2(:));
then increase transparency of the larger one
set(h1,'markeredgealpha',0.05)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by