@@ -174,6 +174,7 @@ def update_colors_select(event):
174
174
175
175
176
176
def create_color_pickers (states , colors ):
177
+ print (states )
177
178
color_picker_list = []
178
179
for state , color in zip (states [0 ], colors ):
179
180
color_picker = pn .widgets .ColorPicker (name = state , value = color )
@@ -183,10 +184,11 @@ def create_color_pickers(states, colors):
183
184
184
185
185
186
@pn .cache
186
- def palette ( res , colors_picked ):
187
+ def palette_ ( states : list [ list [ str ]] , colors_picked : list [ list [ float ]] ):
187
188
cmaps = [single_color_to_colormap (color_picked ) for color_picked in colors_picked ]
188
189
# 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 ])
190
192
191
193
192
194
@pn .cache
@@ -206,7 +208,7 @@ def xlim_auto(output):
206
208
207
209
208
210
@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 ):
210
212
kind = "histogram" if kind == "Stacked histogram" else "boxplot"
211
213
plt .close ("all" )
212
214
fig , ax = plt .subplots ()
@@ -224,12 +226,12 @@ def states_from_data(res, inputs):
224
226
225
227
226
228
@pn .cache
227
- def tableau (res , states , palette ):
229
+ def tableau_pn (res , states , palette ):
228
230
# use a notebook to see the styling
229
231
_ , styler = sd .tableau (
230
232
statistic = res .statistic ,
231
233
var_names = res .var_names ,
232
- states = states ,
234
+ states = res . states ,
233
235
bins = res .bins ,
234
236
palette = palette ,
235
237
)
@@ -392,12 +394,10 @@ def callback_xlim(start, end):
392
394
colors_select .param .value ,
393
395
)
394
396
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 )
398
398
399
399
interactive_figure = pn .bind (
400
- figure ,
400
+ figure_pn ,
401
401
interactive_decomposition ,
402
402
interactive_palette ,
403
403
selector_n_bins ,
@@ -407,7 +407,7 @@ def callback_xlim(start, end):
407
407
)
408
408
409
409
interactive_tableau = pn .bind (
410
- tableau , interactive_decomposition , interactive_states , interactive_palette
410
+ tableau_pn , interactive_decomposition , interactive_states , interactive_palette
411
411
)
412
412
interactive_tableau_states = pn .bind (
413
413
tableau_states , interactive_decomposition , interactive_states
0 commit comments