1 function plot_data_sequence(varargin)
2 %
function plot_data_sequence(model,[grid],data,params[, callbackfigure, cbhandle])
4 % plotting a sequence of data slices on polygonal
5 % 2d grid (constructed from params
if empty) and providing a slider
6 %
for changing between the data
7 % slices. A
new figure is opened.
8 % If further parameters are set, the call is assumed to
9 % stem from a callback-
function
11 % required fields in params:
12 % plot_function: the name of the plot-
function performing
13 % the plotting of a single slice, e.g.
14 % plot_element_data, plot_vertex_data
16 % optional field of params:
17 % title:
string indicating the title of the newly opened figure
18 % clim: 2-vector giving the range of the colormap. If
this is
19 % set, identical range is used
for all slices. Default is
20 % the min and max of all slices.
21 % clim_tight:
if this flag is set, the colorbar is set tightly
22 % to the range of every single data slice. Clearly only clim or
23 % clim_tight should be set.
25 % see also the chosen params.plot_function
for its further params-options
27 % Bernard Haasdonk 9.5.2007
30 if nargin < 5 % no callback, open
new figure
36 txt = uicontrol(f,
'Style',
'text',
'Units',
'normalized',...
37 'Position',[di,di,textwidth,textheight],...
38 'String',
'Slice 1',
'Tag',
'text1');
39 slider = uicontrol(f,
'Style',
'slider',
'Units',
'normalized',...
40 'Position',[di+textwidth+di, di ,1-3*di-textwidth,...
41 textheight],
'Tag',
'slider1',...
42 'Callback',
'plot_data_sequence([],[],[],[],gcbf,gcbo);');
43 ax = axes(
'Units',
'normalized',...
44 'Position',[di,2*di+textheight,1-2*di,1-3*di - textheight],...
48 ud.model = varargin{1};
49 ud.grid = varargin{2};
50 ud.data = varargin{3};
51 ud.params = varargin{4};
54 ud.grid = construct_grid(ud.params);
57 if isfield(ud.params,'title')
58 set(f,'Name',ud.params.title);
61 if ~isfield(ud.params,'clim_tight')
62 ud.params.clim_tight = 0;
65 if isfield(ud.params,'clim') && ud.params.clim_tight
66 error('please only specify one of the parameters clim and clim_tight.');
69 if ~isfield(ud.params,'clim') && ~ud.params.clim_tight
70 ud.params.clim = [min(min(ud.data)), max(max(ud.data))];
71 if ud.params.clim(1) == ud.params.clim(2)
72 ud.params.clim = ud.params.clim + [-eps, +eps];
77 sl = findobj(f,'Tag','slider1');
79 %set(sl,'max',ud.params.nt);
80 %set(sl,'sliderstep',[1/ud.params.nt,1]);
83 set(sl,'max',size(ud.data,2));
84 set(sl,'sliderstep',[1/(size(ud.data,2)-1),1]);
86 set(sl,'max',size(ud.data,2)+eps);
87 set(sl,'visible','off');
88 % set(sl,'sliderstep',[0,0]);
91 th = findobj(f,'Tag','text1');
92 set(th,'String',('data slice 1') );
94 % set(f,'Resize','on');
97 if nargin >=5 % callback-function
98 % disp('entered plot_data_sequence_callback...')
101 % disp(
'performing callback call of plot_fv_data')
102 th = findobj(gcbf,'Tag','text1');
103 v = round(get(gcbo,'value'));
105 set(th,'String',['data slice ',num2str(v)]);
107 % disp('exiting plot_data_sequence_callback...')
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 function replot(fh,oh,v)
112 %disp('entered replot...')
113 ud = get(fh,'Userdata');
114 %if (size(ud.data,2)<v+1)
115 % disp('number of timesteps in U does not match paramt.nt');
117 % d = reshape(ud.data(:,v+1),ud.params.nx,ud.params.ny)';
119 %d = reshape(ud.data(:,v),ud.params.nx,ud.params.ny)';
120 %xr = ud.params.xrange;
121 %x = xr(1):(xr(2)-xr(1))/(ud.params.nx):xr(2);
122 %yr = ud.params.yrange;
123 %y = yr(1):(yr(2)-yr(1))/(ud.params.ny):yr(2);
124 %p=pcolor(x,y,[d,zeros(size(d,1),1);zeros(1,size(d,2)+1)]);
125 %if isfield(ud.params,'no_lines')
126 % % disp('halt in plot_p1_data');
128 % if ud.params.no_lines == 1
129 % set(p,'linestyle','None');
138 % if clim_tight, adapt color-range:
139 if ud.params.clim_tight
140 ud.params.clim = [min(min(d)), max(max(d))];
141 if ud.params.clim(1) == ud.params.clim(2)
142 ud.params.clim = ud.params.clim + [-eps, +eps];
147 ax = findobj(fh,'Tag','axes1');
150 %set(ax,'children',[]);
152 feval(ud.params.plot_function,ud.grid,d,ud.params);
154 %disp('after plot...')
157 set(gca,'Clim',[ud.params.clim(1), ud.params.clim(2)]);
160 %if isfield(ud.params,'show_colorbar') & (ud.params.show_colorbar)
161 % if isfield(ud.params,'colorbar_mode')
162 % colorbar(ud.params.colorbar_mode);
169 %if isfield(ud.params,'no_lines') & (ud.params.no_lines)
170 % set(p,'LineStyle','None');
173 %disp('exiting replot...')