IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
vis_scatter3dgif.m
Go to the documentation of this file.
1 %> @brief GIF animation showing rotation of a 3D scatterplot
2 %> @sa data_draw_scatter_3d.m, uip_vis_scatter3dgif.m
3 classdef vis_scatter3dgif < vis
4  properties
5  %> =[1, 2, 3] Index of features to be uses as coordinates. Must be a 3-element vector.
6  idx_fea = [1, 2, 3];
7  %> =[] . Vector of confidence percentages (between 0 and 1) for drawing the confidence ellipsoids. If left
8  %> empty, no confidence ellipsoid is drawn.
9  confidences = [];
10  %> =0 . Whether or not to annotate the observation names ( @c irdata::obsnames ) on the drawing. <b>Careful</b>:
11  %> figure may become quite jammed and MATLAB responsively slow if there are over a thousand observations.
12  flag_text = 0;
13  %> =-30:8:330 . Rotation angles in degrees
14  rots = -30:8:330;
15  %> ='' . If not specified: scatter3d<nnnn>.gif.
16  filename;
17  end;
18 
19  methods
20  function o = vis_scatter3dgif(o)
21  o.classtitle = '3D Scatterplot - GIF animation';
22  o.inputclass = 'irdata';
23  end;
24  end;
25 
26  methods(Access=protected)
27  function out = do_use(o, obj)
28  out = [];
29  data_draw_scatter_3d(obj, o.idx_fea, o.confidences, o.flag_text);
30 
31  h = gca();
32  p = get(h, 'Position');
33 % axis off;
34 % set(gca, 'Position', [0, 0, 1, 1]);
35  set(gcf, 'Color', 'w');
36 % set(h, 'Position', [.4, .4, .4+p(3)-p(1), .4+p(4)-p(2)]);
37 
38  msgbox(sprintf('Please move and format the legend to your taste, then press Enter at the MATLAB command line.\nNote: don''t delete the legend.'));
39 
40  input('Please press Enter when ready to record animated GIF ');
41 
42  if isempty(o.filename)
43  fn = find_filename('irr_scatter3d', [], 'gif');
44  else
45  fn = o.filename;
46  end;
47 
48 
49  for i = 1:length(o.rots)
50  set(gca, 'View', [o.rots(i), 30]);
51  frame = getframe(gcf);
52 
53 
54  if i == 1
55  [im, map] = rgb2ind(frame.cdata, 256, 'nodither');
56  im(1, 1, 1, length(o.rots)) = 0;
57  end;
58  im(:, :, 1, i) = rgb2ind(frame.cdata, map, 'nodither');
59  end
60  imwrite(im, map, fn, 'DelayTime', 0, 'LoopCount', inf);
61  end;
62  end;
63 end
Property obsnames
(optional) [no]x[1] Cell of strings. Observation names (e.g. file names of the individual spectra) ...
Definition: irdata.m:67
GIF animation showing rotation of a 3D scatterplot.
Dataset class.
Definition: irdata.m:30
Visualization base class.
Definition: vis.m:4
function data_draw_scatter_3d(in data, in idx_fea, in confidences, in textmode)
Analysis Session (AS) base class.
Definition: as.m:6
function find_filename(in prefix, in suffix, in extension, in flag_return_ext)