
how to overlay multiple images using scatter3?
조회 수: 5 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
채택된 답변
jonas
2018년 9월 13일
편집: jonas
2018년 9월 13일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!