Skip to content

Commit

Permalink
renormalize the plots value axis on every update
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Apr 18, 2019
1 parent 4889ab5 commit c1ce965
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions adaptive/notebook_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def in_ipynb():
active_plotting_tasks = dict()


def live_plot(runner, *, plotter=None, update_interval=2, name=None):
def live_plot(runner, *, plotter=None, update_interval=2,
name=None, normalize=True):
"""Live plotting of the learner's data.
Parameters
Expand All @@ -99,15 +100,19 @@ def live_plot(runner, *, plotter=None, update_interval=2, name=None):
Name for the `live_plot` task in `adaptive.active_plotting_tasks`.
By default the name is None and if another task with the same name
already exists that other `live_plot` is canceled.
normalize : bool
Normalize the frame upon each update.
Returns
-------
dm : `holoviews.core.DynamicMap`
The plot that automatically updates every `update_interval`.
"""
if not _holoviews_enabled:
raise RuntimeError("Live plotting is not enabled; did you run "
"'adaptive.notebook_extension()'?")
raise RuntimeError(
"Live plotting is not enabled; did you run "
"'adaptive.notebook_extension()'?"
)

import holoviews as hv
import ipywidgets
Expand All @@ -123,8 +128,10 @@ def plot_generator():
else:
yield plotter(runner.learner)

dm = hv.DynamicMap(plot_generator(),
streams=[hv.streams.Stream.define('Next')()])
steams = [hv.streams.Stream.define("Next")()]
dm = hv.DynamicMap(plot_generator(), streams=streams).opts(
norm=dict(framewise=normalize)

cancel_button = ipywidgets.Button(description='cancel live-plot',
layout=ipywidgets.Layout(width='150px'))

Expand Down

0 comments on commit c1ce965

Please sign in to comment.