-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsaveGraphAsGif.m
More file actions
31 lines (27 loc) · 847 Bytes
/
Copy pathsaveGraphAsGif.m
File metadata and controls
31 lines (27 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
% Plot 3D graph, rotate and create .gif
% Close any open figure windows
close all
% Create graph
g = graph(mainCharData.Character,mainCharData.Movie);
figure('units','normalized','outerposition',[0 0 1 1])
colormap hsv
p = plot(g,'Layout','force3','UseGravity','on',...
'MarkerSize',degree(g));
p.NodeCData = degree(g);
axis off
clear frame
% Rotate and save as .gif
outfile = 'marvel_graph_mainchar1.gif';
for theta = -180:5:90
view(theta,0)
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% On the first loop, create the file. In subsequent loops, append.
if theta==-180
imwrite(imind,cm,outfile,'gif','DelayTime',.1,'loopcount',inf);
else
imwrite(imind,cm,outfile,'gif','DelayTime',.1,'writemode','append');
end
end