Incremental display of data points in a 3D scattered plot
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Greek McCoy
el 22 de Mzo. de 2022
Comentada: Mathieu NOE
el 22 de Mzo. de 2022
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/936854/image.jpeg)
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.
0 comentarios
Respuesta aceptada
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
Más respuestas (0)
Ver también
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!