Borrar filtros
Borrar filtros

Incremental display of data points in a 3D scattered plot

4 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 22 de Mzo. de 2022
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 comentarios
Greek McCoy
Greek McCoy el 22 de Mzo. de 2022
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 el 22 de Mzo. de 2022
My pleasure !
all the best

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by