Noskario
Noskario

Reputation: 674

Coordinate system not updating in holoviews' DynamicMap

I try to implement an interactive histogram in holoview where you can change the upper limit (so I can decide whether I want to see outliers or not). I am using bokeh as backend.

But unfortunately adjusting the slidebar only recomputes the histogram but does not adjust the x- and y-coordinates so you have to zoom in/out manually you want to see the changes. Is this a normal behaviour?

I give you a minimal example:

import numpy as np
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')

a=np.array([1,1,11,1,1,1,1,1,1,1,2,2,2,2,2,5,5,5,30])
def hist_creater(upper_limit):
    frequencies, edges=np.histogram(a,range=(0,upper_limit),bins=10)
    return hv.Histogram((edges, frequencies))
    
dmap=hv.DynamicMap(hist_creater,kdims=["upper_bound_for_weight"]).redim.range(upper_bound_for_weight=(10,100))
dmap.opts(width=300)          

Upvotes: 1

Views: 440

Answers (1)

James A. Bednar
James A. Bednar

Reputation: 3255

Note that you can already zoom on the axes in Bokeh to look at any region you like if you select the scroll-zoom tool. Thus you don't necessarily need a separate widget for this purpose, but maybe I'm misunderstanding the goal here.

In any case, if you want the axis bounds to be recomputed again for each new frame in this DynamicMap, just specify dmap.opts(width=300, framewise=True). By default it tries to keep your initial range the same so that you can see changes in the data, but framewise=True tells it to instead auto-range every time the data changes.

Upvotes: 3

Related Questions