Mercurial > repos > public > sbplib
annotate +anim/setup_time_quantity_plot.m @ 577:e45c9b56d50d feature/grids
Add an Empty grid class
The need turned up for the flexural code when we may or may not have a grid for the open water and want to plot that solution.
In case there is no open water we need an empty grid to plot the empty gridfunction against to avoid errors.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 07 Sep 2017 09:16:12 +0200 |
parents | a38c243991d0 |
children | 2ffa82fb5172 |
rev | line source |
---|---|
0 | 1 function [update_data, plot_handles] = setup_time_quantity_plot(yfun) |
2 default_arg('yfun',@(y)y); | |
3 | |
69
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
4 if isa(yfun,'function_handle') |
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
5 yfun = {yfun}; |
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
6 end |
f87003695677
Moved drawno out of plot update functions for huge performance boost.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
7 |
0 | 8 t = []; |
9 for i = 1:length(yfun) | |
72
942cb3c53a47
Simplified implementation of time quantity plot.
Jonatan Werpers <jonatan@werpers.com>
parents:
70
diff
changeset
|
10 plot_handles(i) = animatedline(); |
0 | 11 end |
12 | |
13 axis_handle = gca; | |
14 | |
15 function update(t_now,varargin) | |
16 if ishandle(axis_handle) | |
72
942cb3c53a47
Simplified implementation of time quantity plot.
Jonatan Werpers <jonatan@werpers.com>
parents:
70
diff
changeset
|
17 % t = [t t_now]; |
0 | 18 for j = 1:length(yfun) |
72
942cb3c53a47
Simplified implementation of time quantity plot.
Jonatan Werpers <jonatan@werpers.com>
parents:
70
diff
changeset
|
19 addpoints(plot_handles(j),t_now,yfun{j}(varargin{:})); |
0 | 20 end |
70
243c558dc3ae
Made end of animated quantity plot nicer.
Jonatan Werpers <jonatan@werpers.com>
parents:
69
diff
changeset
|
21 |
72
942cb3c53a47
Simplified implementation of time quantity plot.
Jonatan Werpers <jonatan@werpers.com>
parents:
70
diff
changeset
|
22 [t,~] = getpoints(plot_handles(1)); |
942cb3c53a47
Simplified implementation of time quantity plot.
Jonatan Werpers <jonatan@werpers.com>
parents:
70
diff
changeset
|
23 if t(1) < t(end) |
74
d0df12c03aac
Added missing axis_handle reference.
Jonatan Werpers <jonatan@werpers.com>
parents:
72
diff
changeset
|
24 xlim(axis_handle, [t(1) t(end)]); |
70
243c558dc3ae
Made end of animated quantity plot nicer.
Jonatan Werpers <jonatan@werpers.com>
parents:
69
diff
changeset
|
25 end |
0 | 26 end |
27 end | |
28 update_data = @update; | |
29 end |