2 %
function p =
plot_sequence(data,grid,params[,callbackfigure, cbhandle])
3 % plotting a sequence of data slices on polygonal
4 % 2d grid (constructed from params
if empty) and providing a slider
5 %
for changing between the data
8 % A
new figure is opened and the handle returned in p. If further parameters
9 % are set, the call is assumed to stem from a callback-
function
11 % Every column of data is interpreted as one discrete
function
12 % dof vector forwarded to the params.plot()
function.
15 % varargin: usually called with 3 arguments:
17 % - data - data vector to be plotted
18 % - grid - the underlying grid
19 % - params - plotting parameters
21 % Alternatively, there can be 5 arguments:
22 % @code plot_sequence(data, grid, params, callbackfigure, cbhandle) @endcode
23 % This function is set as a callback function for the time slider
24 % uicontrol. The additional arguments are:
25 % - callbackfigure - handle to the figure
26 % - cbhandle - handle to the object calling the callback function. This
27 % is usually the time slider.
30 % p : figure handle of plot
32 % required fields in params:
33 % - 'plot' -- pointer to the plot-function performing the plotting of a
34 % single slice, e.g. plot_element_data(), plot_vertex_data(),
35 % fv_plot(), ldg_plot().
37 % optional field of params:
38 % - 'title' -- string indicating the title of the newly opened figure
39 % - 'clim' -- 2-vector giving the range of the colormap. If this is set,
40 % identical range is used for all slices. Default is the min and
42 % - 'clim_tight' -- if this flag is set, the colorbar is set tightly to the
43 % range of every single data slice. Clearly only one of
44 % 'clim' or 'clim_tight' should be set.
46 % see also the chosen 'params.plot_function' for its further params-options
48 % Bernard Haasdonk 9.5.2007
51 if nargin < 4 % no callback, open new figure
58 txt = uicontrol(f,
'Style',
'text',
'Units',
'normalized',...
59 'Position',[di,di,textwidth,textheight],...
60 'String',
'Slice 1',
'Tag',
'text1');
61 slider = uicontrol(f,
'Style',
'slider',
'Units',
'normalized',...
62 'Position',[di+textwidth+di, di ,1-3*di-textwidth,...
63 textheight],
'Tag',
'slider1',...
64 'Callback',
'plot_sequence([],[],[],[],gcbf,gcbo);');
65 ax = axes(
'Units',
'normalized',...
66 'Position',[di,2*di+textheight,1-2*di,1-3*di - textheight],...
70 ud.data = varargin{1};
71 ud.grid = varargin{2};
72 ud.params = varargin{3};
75 ud.grid = construct_grid(ud.params);
78 if isfield(ud.params,'title')
79 set(f,'Name',ud.params.title);
82 if ~isfield(ud.params,'clim_tight')
83 ud.params.clim_tight = 0;
86 if isfield(ud.params,'clim') && ud.params.clim_tight
87 error('please only specify one of the parameters clim and clim_tight.');
90 if ~isfield(ud.params,'clim') && ~ud.params.clim_tight
91 ud.params.clim = [min(min(ud.data)), max(max(ud.data))];
92 if ud.params.clim(1) == ud.params.clim(2)
93 ud.params.clim = ud.params.clim + [-eps, +eps];
98 sl = findobj(f,'Tag','slider1');
100 %set(sl,'max',ud.params.nt);
101 %set(sl,'sliderstep',[1/ud.params.nt,1]);
104 set(sl,'max',size(ud.data,2));
105 set(sl,'sliderstep',[1/(size(ud.data,2)-1),1]);
107 set(sl,'max',size(ud.data,2)+eps);
108 set(sl,'visible','off');
109 % set(sl,'sliderstep',[0,0]);
112 th = findobj(f,'Tag','text1');
113 set(th,'String',('data slice 1') );
115 % set(f,'Resize','on');
119 if nargin >=4 % callback-function
122 % disp(
'performing callback call of plot_fv_data')
123 th = findobj(gcbf,'Tag','text1');
124 v = round(get(gcbo,'value'));
126 set(th,'String',['data slice ',num2str(v)]);
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 function replot(fh,oh,v)
133 ud = get(fh,'Userdata');
137 % if clim_tight, adapt color-range:
138 if ud.params.clim_tight
139 ud.params.clim = [min(min(d)), max(max(d))];
140 if ud.params.clim(1) == ud.params.clim(2)
141 ud.params.clim = ud.params.clim + [-eps, +eps];
146 ax = findobj(fh,'Tag','axes1');
149 ud.params.plot(ud.grid,d,ud.params);
151 set(gca,'Clim',[ud.params.clim(1), ud.params.clim(2)]);
function p = plot_sequence(varargin)
plotting a sequence of data slices on polygonal 2d grid (constructed from params if empty) and provid...