holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.73k stars 516 forks source link

Title of holoviews HoloMap does not change properly with widget change #1041

Open Jacob-Barhak opened 4 years ago

Jacob-Barhak commented 4 years ago

When having multiple widgets the title of a holoviews object does not change properly. Here is an example that was constructed using: Python version is: 2.7.15 (default, Jul 2 2019, 00:55:11) [MSC v.1500 64 bit (AMD64)] holoviews version 1.13.0a22 panel version 0.8.0rc2.post8+g4420258 bokeh version 1.4.0

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

VecLength = 21
ParamNames = ['p_'+str(i) for i in range(VecLength)]

MixtureHolomapDict = {}
for CopyEnum in range(7):        
    for IterationToPlot in range(1,6):
        np.random.seed(0)
        ParamValues = list(np.random.random(VecLength) + (np.random.random(VecLength)*IterationToPlot/100))
        BarSources = dict(Param=ParamNames, Value=ParamValues)   
        Title = 'Mixture Iteration %s'%str(IterationToPlot)          
        Bars = hv.Bars(BarSources, kdims=['Param'], vdims = ['Value']).opts(xrotation=90, title = Title )
        MixtureHolomapDict[IterationToPlot, CopyEnum] = Bars

p = hv.HoloMap(MixtureHolomapDict, kdims=['Iteration','Copy'])
hv.save(p,'titlebug.html')
p

The resulting html file does change the image when sliding the first slider, yet does not change the title to correspond with the slider. However, if the second slider is dragged all the way to the right, then the title changes when dragging the top slider.

philippjfr commented 4 years ago

This is a Panel issue.

Jacob-Barhak commented 4 years ago

This issue is resolve by: https://github.com/holoviz/panel/pull/1040/ . Here is resolution code:

import holoviews as hv, numpy as np, panel as pn
hv.extension('bokeh') 
pn.extension(safe_embed=True) 

VecLength = 21
ParamNames = ['p_'+str(i) for i in range(VecLength)]

MixtureHolomapDict = {}
for CopyEnum in range(7):        
    for IterationToPlot in range(1,6):
        np.random.seed(0)
        ParamValues = list(np.random.random(VecLength) + (np.random.random(VecLength)*IterationToPlot/100))
        BarSources = dict(Param=ParamNames, Value=ParamValues)   
        Title = 'Mixture Iteration %s'%str(IterationToPlot)          
        Bars = hv.Bars(BarSources, kdims=['Param'], vdims = ['Value']).opts(xrotation=90, title = Title )
        MixtureHolomapDict[IterationToPlot, CopyEnum] = Bars

p = hv.HoloMap(MixtureHolomapDict, kdims=['Iteration','Copy'])
hv.save(p,'titlebug.html')
p

When the https://github.com/holoviz/panel/tree/safe_embed branch is merged into master, this issue can be closed

philippjfr commented 4 years ago

I'll keep this open until safe_embed is the default.