@@ -84,7 +84,8 @@ def in_ipynb():
8484active_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 (scale to fit) 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,12 @@ 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 )
133+
134+ if normalize :
135+ dm = dm .map (lambda obj : obj .opts (framewise = True ), hv .Element )
136+
128137 cancel_button = ipywidgets .Button (description = 'cancel live-plot' ,
129138 layout = ipywidgets .Layout (width = '150px' ))
130139
0 commit comments