Browse code

wrap all plots in an Overlay

Bas Nijholt authored on 14/10/2019 13:19:39
Showing 1 changed files
... ...
@@ -590,7 +590,7 @@ class Learner1D(BaseLearner):
590 590
 
591 591
         Returns
592 592
         -------
593
-        plot : `holoviews.Scatter`, `holoviews.Path`, or `holoviews.Overlay`
593
+        plot : `holoviews.Overlay`
594 594
             Plot of the evaluated data.
595 595
         """
596 596
         if scatter_or_line not in ("scatter", "line"):
... ...
@@ -600,13 +600,15 @@ class Learner1D(BaseLearner):
600 600
         xs, ys = zip(*sorted(self.data.items())) if self.data else ([], [])
601 601
         if scatter_or_line == "scatter":
602 602
             if self.vdim == 1:
603
-                p = hv.Scatter((xs, ys))
603
+                plots = [hv.Scatter((xs, ys))]
604 604
             else:
605
-                scatters = [hv.Scatter((xs, _ys)) for _ys in np.transpose(ys)]
606
-                p = hv.Overlay(scatters)
605
+                plots = [hv.Scatter((xs, _ys)) for _ys in np.transpose(ys)]
607 606
         else:
608
-            p = hv.Path((xs, ys))
607
+            plots = [hv.Path((xs, ys))]
609 608
 
609
+        # Put all plots in an Overlay because a DynamicMap can't handle changing
610
+        # datatypes, e.g. when `vdim` isn't yet known and the live_plot is running.
611
+        p = hv.Overlay(plots)
610 612
         # Plot with 5% empty margins such that the boundary points are visible
611 613
         margin = 0.05 * (self.bounds[1] - self.bounds[0])
612 614
         plot_bounds = (self.bounds[0] - margin, self.bounds[1] + margin)