How to create a 3D scatterplot animation

preview_player
Показать описание
In this video I explain how to create a 3D scatterplot animation using an Octave (also Matlab) script and Image Magick tool.

The source code is as follows:

# call octave to create all snapshots
octave create_snapshots.m
# reduce size of images, if needed
mogrify -resize 500x375 scatter*.png
# create animated GIF
# if you want to create a swf with the animation

file 2 - create_snapshots.m

clear all;

# define velues for each axis (in this case random values)
axis_X = rand(1, 400);
axis_Y = rand(1, 400);
axis_Z = rand(1, 400);

# create 360 snapshots (1 per degree)
figure(1);
t = 100;
for degree=1:360
# clear graph
clf;

# plot 3d snapshot with small dots "."
plot3(axis_X, axis_Y, axis_Z, ".");

# configure label names and axis intervals [0, 1]
xlabel("X Label");
ylabel("Y Label");
zlabel("Z Label");
axis([0 1 0 1 0 1]);

# rotate the graph according to current degree
view(degree, 30 + 15 * sin(degree/60));

# save the current snapshot file
plotname = ['scatter_t', num2str(t), '.png'];
print(plotname, '-dpng');
t = t + 1;
end;
Рекомендации по теме
Комментарии
Автор

nice work thank you lot it work in octave 4 on fedora 24

rafeef
Автор

Hi. I am so sorry if I asked silly question. I am working on MATLAB 3D scatter plot for my presentation. I would be nice if i can export it as you show in the video. I have a big data (4, 000+) for each X, Y, Z in mat file. Can I use something like load('myfile.mat') in create_snapshots.m to access my data in Octava? and How?

oomlette
Автор

Hi, nice idea.
Why don't you put the {"clear graph", "plot 3d snapshot" and "configure label and axis"} sections outside the loop?
Do you see a big performance gain if you do so? And if you use 10 times as much points?

TheEliasVDS
Автор

hello I'm using matlab for a first time and i want to make a 3D scatter Plot where can i find help cause i'm confused

noxolohlongwa
Автор

Tried this in Ubuntu 18.04 with octave. But gnuplot somehow messes up and crashes, and the X11 croaks and makes the screen freeze. All I can do is hard reboot.

reinerwilhelms-tricarico
Автор

ok, removed the png3swf line. Now get this error:
./create_animation.sh: line 1: $'\r': command not found
': No such file or directory @ error/blob.c/OpenBlob/2638.
' @ image format `scatter*.png

elecchal
join shbcf.ru