changeset 72:942cb3c53a47

Simplified implementation of time quantity plot.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 23 Nov 2015 14:55:58 +0100
parents 1edee9e1ea41
children a5fa3c2d0aa3
files +anim/setup_time_quantity_plot.m
diffstat 1 files changed, 6 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/+anim/setup_time_quantity_plot.m	Mon Nov 23 14:34:02 2015 +0100
+++ b/+anim/setup_time_quantity_plot.m	Mon Nov 23 14:55:58 2015 +0100
@@ -7,10 +7,7 @@
 
     t = [];
     for i = 1:length(yfun)
-        plot_handles(i) = line(0,0);
-        plot_handles(i).XData = [];
-        plot_handles(i).YData = [];
-        quantities{i} = [];
+        plot_handles(i) = animatedline();
     end
 
     axis_handle = gca;
@@ -19,15 +16,14 @@
 
     function update(t_now,varargin)
         if ishandle(axis_handle)
-            t = [t t_now];
+            % t = [t t_now];
             for j = 1:length(yfun)
-                quantities{j} = [quantities{j} yfun{j}(varargin{:})];
-                plot_handles(j).XData = t;
-                plot_handles(j).YData = quantities{j};
+                addpoints(plot_handles(j),t_now,yfun{j}(varargin{:}));
             end
 
-            if t(end) > t(1)
-                xlim([t(1) 1.1*t(end)]);
+            [t,~] = getpoints(plot_handles(1));
+            if t(1) < t(end)
+                xlim([t(1) t(end)]);
             end
         end
     end