Skip to content

Commit c1ce965

Browse files
committed
renormalize the plots value axis on every update
1 parent 4889ab5 commit c1ce965

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

adaptive/notebook_integration.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def in_ipynb():
8484
active_plotting_tasks = dict()
8585

8686

87-
def live_plot(runner, *, plotter=None, update_interval=2, name=None):
87+
def live_plot(runner, *, plotter=None, update_interval=2,
88+
name=None, normalize=True):
8889
"""Live plotting of the learner's data.
8990
9091
Parameters
@@ -99,15 +100,19 @@ def live_plot(runner, *, plotter=None, update_interval=2, name=None):
99100
Name for the `live_plot` task in `adaptive.active_plotting_tasks`.
100101
By default the name is None and if another task with the same name
101102
already exists that other `live_plot` is canceled.
103+
normalize : bool
104+
Normalize the frame upon each update.
102105
103106
Returns
104107
-------
105108
dm : `holoviews.core.DynamicMap`
106109
The plot that automatically updates every `update_interval`.
107110
"""
108111
if not _holoviews_enabled:
109-
raise RuntimeError("Live plotting is not enabled; did you run "
110-
"'adaptive.notebook_extension()'?")
112+
raise RuntimeError(
113+
"Live plotting is not enabled; did you run "
114+
"'adaptive.notebook_extension()'?"
115+
)
111116

112117
import holoviews as hv
113118
import ipywidgets
@@ -123,8 +128,10 @@ def plot_generator():
123128
else:
124129
yield plotter(runner.learner)
125130

126-
dm = hv.DynamicMap(plot_generator(),
127-
streams=[hv.streams.Stream.define('Next')()])
131+
steams = [hv.streams.Stream.define("Next")()]
132+
dm = hv.DynamicMap(plot_generator(), streams=streams).opts(
133+
norm=dict(framewise=normalize)
134+
128135
cancel_button = ipywidgets.Button(description='cancel live-plot',
129136
layout=ipywidgets.Layout(width='150px'))
130137

0 commit comments

Comments
 (0)