Skip to content

Commit a24fe9b

Browse files
committed
set 'scatter_or_line' by default to 'scatter'
1 parent 82a55f2 commit a24fe9b

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

adaptive/learner/learner1D.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -580,33 +580,32 @@ def _loss(self, mapping, ival):
580580
loss = mapping[ival]
581581
return finite_loss(ival, loss, self._scale[0])
582582

583-
def plot(self, *, scatter_or_line=None):
583+
def plot(self, *, scatter_or_line="scatter"):
584584
"""Returns a plot of the evaluated data.
585585
586+
Parameters
587+
----------
588+
scatter_or_line : str, default: "scatter"
589+
Plot as a scatter plot ("scatter") or a line plot ("line").
590+
586591
Returns
587592
-------
588-
plot : `holoviews.element.Scatter` (if vdim=1)\
589-
else `holoviews.element.Path`
593+
plot : `holoviews.Scatter`, `holoviews.Path`, or `holoviews.Overlay`
590594
Plot of the evaluated data.
591-
scatter_or_line : str, optional
592-
Plot as a scatter plot ("scatter") or a line plot ("line").
593-
By default a line plot will be chosen if the data consists of
594-
vectors, otherwise it is a scatter plot.
595595
"""
596+
if scatter_or_line not in ("scatter", "line"):
597+
raise ValueError("scatter_or_line must be 'scatter' or 'line'")
596598
hv = ensure_holoviews()
597599

598600
xs, ys = zip(*sorted(self.data.items())) if self.data else ([], [])
599-
if self.vdim == 1:
600-
if scatter_or_line is None or scatter_or_line == "scatter":
601-
p = hv.Path([]) * hv.Scatter((xs, ys))
602-
else:
603-
p = hv.Path((xs, ys)) * hv.Scatter()
604-
else:
605-
if scatter_or_line is None or scatter_or_line == "line":
606-
p = hv.Path((xs, ys)) * hv.Scatter([])
601+
if scatter_or_line == "scatter":
602+
if self.vdim == 1:
603+
p = hv.Scatter((xs, ys))
607604
else:
608605
scatters = [hv.Scatter((xs, _ys)) for _ys in np.transpose(ys)]
609-
p = hv.Path([]) * hv.Overlay(scatters)
606+
p = hv.Overlay(scatters)
607+
else:
608+
p = hv.Path((xs, ys))
610609

611610
# Plot with 5% empty margins such that the boundary points are visible
612611
margin = 0.05 * (self.bounds[1] - self.bounds[0])

0 commit comments

Comments
 (0)