Skip to content

Commit 62a7d6b

Browse files
committed
wrap all plots in an Overlay
1 parent a24fe9b commit 62a7d6b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

adaptive/learner/learner1D.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def plot(self, *, scatter_or_line="scatter"):
590590
591591
Returns
592592
-------
593-
plot : `holoviews.Scatter`, `holoviews.Path`, or `holoviews.Overlay`
593+
plot : `holoviews.Overlay`
594594
Plot of the evaluated data.
595595
"""
596596
if scatter_or_line not in ("scatter", "line"):
@@ -600,13 +600,15 @@ def plot(self, *, scatter_or_line="scatter"):
600600
xs, ys = zip(*sorted(self.data.items())) if self.data else ([], [])
601601
if scatter_or_line == "scatter":
602602
if self.vdim == 1:
603-
p = hv.Scatter((xs, ys))
603+
plots = [hv.Scatter((xs, ys))]
604604
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)]
607606
else:
608-
p = hv.Path((xs, ys))
607+
plots = [hv.Path((xs, ys))]
609608

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)
610612
# Plot with 5% empty margins such that the boundary points are visible
611613
margin = 0.05 * (self.bounds[1] - self.bounds[0])
612614
plot_bounds = (self.bounds[0] - margin, self.bounds[1] + margin)

0 commit comments

Comments
 (0)