Incremental display of data points in a 3D scattered plot

조회 수: 6 (최근 30일)
Greek McCoy
Greek McCoy 2022년 3월 22일
댓글: Mathieu NOE 2022년 3월 22일
Dear all,
I have with me the attached dataset which I will like to display by a gradual representation (accumulation of the plot points in a point by point format until all plot points are displayed) in a scattered plot.
Below here is my code:
%clear all;
%close all;
clc
A = load ('TimespanTutorial.txt');
Time = A (:,1) ;
x = A (:,2 ) ;
y = A (:,3 ) ;
z = A (:,4 ) ;
Amplitude = A (:,5) ;
scatter3 (x , y, z, 30, Amplitude);
title ('TimespanTutorial')
xlim ([-50.00 50.00])
ylim ([-50.00 50.00])
zlim ([0.00 100.00])
xlabel ('Breath /m')
ylabel ('Width /m')
zlabel ('Height /m')
pbaspect([1 1 2])
H = colorbar ;
ylabel (H, 'Amplitude')
hold on
r = 25.000;
[X,Y,Z] = cylinder(r);
hsurf = surf (X,Y,Z*100, 'EdgeColor', 'none', 'FaceAlpha', 0.2);
patch(X(1,:),Y(1,:),Z(1,:), hsurf.CData(1,:), 'FaceAlpha', 0.2)
patch(X(1,:),Y(1,:),Z(2,:), hsurf.CData(1,:), 'FaceAlpha', 0.2)
hold off
drawnow
for i = 1:A (:,1)
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if i == 1
imwrite(imind, cm, 'myanimation.gif', 'gif', 'Loopcount', 100);
else
imwrite(imind, cm, 'myanimation.gif', 'gif', 'WriteMode', 'append');
end
end
My results show all the plot points in the graph accurately but not in an incremental sequence as desired.
Is there any possibilty that I may get some assitance?
I am open to saving the incremental display of the plot points as photos to create a short movie afterwards.

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 3월 22일
hello
this would be my suggestion
adapt the amount of pause to your needs
all the best
clc
A = load ('TimespanTutorial.txt');
Time = A (:,1) ;
x = A (:,2 ) ;
y = A (:,3 ) ;
z = A (:,4 ) ;
Amplitude = A (:,5) ;
scatter3 (x(1) , y(1), z(1), 30, Amplitude(1));
title ('TimespanTutorial')
xlim ([-50.00 50.00])
ylim ([-50.00 50.00])
zlim ([0.00 100.00])
xlabel ('Breath /m')
ylabel ('Width /m')
zlabel ('Height /m')
pbaspect([1 1 2])
H = colorbar ;
ylabel (H, 'Amplitude')
hold on
r = 25.000;
[X,Y,Z] = cylinder(r);
hsurf = surf (X,Y,Z*100, 'EdgeColor', 'none', 'FaceAlpha', 0.2);
patch(X(1,:),Y(1,:),Z(1,:), hsurf.CData(1,:), 'FaceAlpha', 0.2)
patch(X(1,:),Y(1,:),Z(2,:), hsurf.CData(1,:), 'FaceAlpha', 0.2)
% gif first frame export
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind, cm, 'myanimation.gif', 'gif', 'Loopcount', numel(Amplitude));
for ci = 2:numel(Amplitude)
scatter3 (x(ci) , y(ci), z(ci), 30, Amplitude(ci));
pause(0.25);
drawnow
% gif remaining frames export
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite(imind, cm, 'myanimation.gif', 'gif', 'WriteMode', 'append');
end
hold off
  댓글 수: 5
Greek McCoy
Greek McCoy 2022년 3월 22일
Hello Mathieu,
I appreciate your prompt response and the attached files.
The idea of a forced min / max value colorbar is more suitable and works to perfection.
Thank you so much for your assistance.
--
Regards,
GM
Mathieu NOE
Mathieu NOE 2022년 3월 22일
My pleasure !
all the best

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by