@@ -174,6 +174,7 @@ def update_colors_select(event):
174174
175175
176176def create_color_pickers (states , colors ):
177+ print (states )
177178 color_picker_list = []
178179 for state , color in zip (states [0 ], colors ):
179180 color_picker = pn .widgets .ColorPicker (name = state , value = color )
@@ -183,10 +184,11 @@ def create_color_pickers(states, colors):
183184
184185
185186@pn .cache
186- def palette ( res , colors_picked ):
187+ def palette_ ( states : list [ list [ str ]] , colors_picked : list [ list [ float ]] ):
187188 cmaps = [single_color_to_colormap (color_picked ) for color_picked in colors_picked ]
188189 # Reverse order as in figures high values take the first colors
189- return sd .palette (res .states [::- 1 ], cmaps = cmaps [::- 1 ])
190+ states = [len (states_ ) for states_ in states ]
191+ return sd .palette (states [::- 1 ], cmaps = cmaps [::- 1 ])
190192
191193
192194@pn .cache
@@ -206,7 +208,7 @@ def xlim_auto(output):
206208
207209
208210@pn .cache
209- def figure (res , palette , n_bins , xlim , kind , output_name ):
211+ def figure_pn (res , palette , n_bins , xlim , kind , output_name ):
210212 kind = "histogram" if kind == "Stacked histogram" else "boxplot"
211213 plt .close ("all" )
212214 fig , ax = plt .subplots ()
@@ -224,12 +226,12 @@ def states_from_data(res, inputs):
224226
225227
226228@pn .cache
227- def tableau (res , states , palette ):
229+ def tableau_pn (res , states , palette ):
228230 # use a notebook to see the styling
229231 _ , styler = sd .tableau (
230232 statistic = res .statistic ,
231233 var_names = res .var_names ,
232- states = states ,
234+ states = res . states ,
233235 bins = res .bins ,
234236 palette = palette ,
235237 )
@@ -392,12 +394,10 @@ def callback_xlim(start, end):
392394 colors_select .param .value ,
393395)
394396
395- interactive_palette = pn .bind (
396- palette , interactive_decomposition , colors_select .param .value
397- )
397+ interactive_palette = pn .bind (palette_ , interactive_states , colors_select .param .value )
398398
399399interactive_figure = pn .bind (
400- figure ,
400+ figure_pn ,
401401 interactive_decomposition ,
402402 interactive_palette ,
403403 selector_n_bins ,
@@ -407,7 +407,7 @@ def callback_xlim(start, end):
407407)
408408
409409interactive_tableau = pn .bind (
410- tableau , interactive_decomposition , interactive_states , interactive_palette
410+ tableau_pn , interactive_decomposition , interactive_states , interactive_palette
411411)
412412interactive_tableau_states = pn .bind (
413413 tableau_states , interactive_decomposition , interactive_states
0 commit comments