How to color the atomic position in 3D scatter plot

조회 수: 2 (최근 30일)
Sara
Sara 2020년 9월 11일
편집: Sara 2020년 9월 11일
Hi there,
I have a txt data from simulated image. I load the txt and use scattering 3D fucntion to plot the x,y and z coordination.
what I want to do is colot the Fe and O and visualize them in 3D scattering. I want to distangush between the Fe and O.

채택된 답변

Star Strider
Star Strider 2020년 9월 11일
Try this:
T1 = readtable('Fe3O4_1.txt');
x = T1.Var4;
y = T1.Var5;
z = T1.Var6;
[AtomLbl,ID] = findgroups(T1.Var2);
FeLbl = (AtomLbl == 1);
OLbl = (AtomLbl == 2);
figure
Feh = scatter3(x(FeLbl), y(FeLbl), z(FeLbl), AtomLbl(FeLbl)*20, AtomLbl(FeLbl), 'filled');
hold on
Oh = scatter3(x(OLbl), y(OLbl), z(OLbl), AtomLbl(OLbl)*30, AtomLbl(OLbl), 'filled');
hold off
grid on
axis('equal')
colormap([1 0 0; 0 1 0])
legend([Feh, Oh], ID)
xlabel('x')
ylabel('y')
zlabel('z')
producing:
.
  댓글 수: 2
Sara
Sara 2020년 9월 11일
prefect answer, thank you for your help.
Star Strider
Star Strider 2020년 9월 11일
Thank you! As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by