Ich habe einige Schwierigkeiten, den Widget-Rückruf mit Bokeh zu verwenden. Mit Hilfe eines Checkbox-Widgets möchte ich die entsprechenden Plots ein-/ausblenden.Bokeh: Verwenden von Checkbox-Widget zum Ausblenden und Anzeigen von Plots
Der Unterschied mit this question, ist, dass ich eine Grafik für jede Glyphe (und nicht alle Glyphen auf einer einzigen Parzelle) möchte. Wenn ich für "example" ein Häkchen bei "b" anklicke, möchte ich ein neues Diagramm der Glyphe sehen.
Edit: Neue Version von meinem Code
from bokeh.io import output_file, show
from bokeh.layouts import column, widgetbox, row
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.models.widgets import CheckboxGroup
from bokeh.models import CustomJS
import pandas as pd
import numpy as np
if __name__ == '__main__':
# Plot tools
TOOLS = 'box_select,box_zoom,reset'
# Data Source
df = pd.DataFrame(np.random.randn(10, 5), columns=['a', 'b', 'c', 'd', 'e'])
source = ColumnDataSource(df)
# Create a new glyph and share ranges
g = figure(plot_width=1300, plot_height=150, title='a', tools=TOOLS)
g.circle(source=source, x='a', y='a')
glyph_list = []
for glyph in range(0, len(source.column_names)):
glyph_list.append((figure(plot_width=1300, plot_height=150, x_range=g.x_range, title=source.column_names[glyph],
tools=TOOLS)))
glyph_list[glyph].circle(source=source, x='a', y=source.column_names[glyph])
# Select the glyphs to plot
initial_list = [0] * len(source.column_names)
## example of a change
initial_list[2] = 1
# Callback
code = """
????
"""
callback = CustomJS(args=dict(source=source), code=code) #????
# Add checkbox widget
checkbox_group = CheckboxGroup(labels=source.column_names,
callback=callback,
active=initial_list)
plot_list = []
for i in range(0, len(source.column_names)):
if checkbox_group.active[i] == 1:
plot_list.append(glyph_list[i])
checkbox_group.js_on_change('active', callback) # ???
layout = row(column(plot_list), widgetbox(checkbox_group))
show(layout)
Können Sie näher auf“... ein Grundstück für jede Daten (und nicht alle Zeilen auf einer einzigen Parzelle) ... ". Meinst du das sichtbar machen an/aus verschiedenen Achsen? Diese Achsen sind in einem Raster? wären sie in einer Spalte mit Dimensionen: Zeilen x 1? oder ein Raster: Zeilen x Spalten? –