Ich versuche, eine Spanne in Bokeh mit Jupyter Widgets zu machen.Aktualisieren Sie eine Bokeh Span mit einem Interaktionselement in Jupyter Notebook
from ipywidgets import interact
import numpy as np
from scipy.stats import norm
from bokeh.sampledata.daylight import daylight_warsaw_2013
from bokeh.io import push_notebook, show, output_notebook
from bokeh.plotting import figure
from bokeh.models import Span
output_notebook()
p = figure()
x_axis = np.arange(-10, 10, 0.001)
# Mean = 0, SD = 2.
y_axis = norm.pdf(x_axis,0,2)
p.line(x_axis, y_axis, line_dash='solid', line_width=2)
cutoff = Span(location=1,
dimension='height', line_color='green',
line_dash='dashed', line_width=2)
p.add_layout(cutoff)
show(p, notebook_handle=True)
def update(new_cutoff_location):
cutoff.location = new_cutoff_location
push_notebook()
interact(update, new_cutoff_location = 1.0)
Wenn ich diesen Code ausführen ich ValueError: PATCH-DOC message requires at least one event
bei push_notebook()
. Ich vermute, das zeigt an, dass das Update auf cutoff.location
nicht erkannt wird, also sieht es so aus, als ob keine Änderungen gesendet werden. Das Übergeben des Griffs scheint keinen Unterschied zu machen. Wenn man sich den Beispielcode in this github issue anschaut, sieht es so aus, als ob es eine set
Methode für Span-Elemente gab, aber es scheint keine auf meinem Span-Element cutoff
zu sein. Vielleicht gibt es eine andere Funktion, die ich anrufen soll, um die Änderung zu registrieren?
Ich bin auf Bokeh 0.12.11 mit jupyter 1.0.0, jupyter-Client 5.1.0, jupyter-Konsole 5.2.0 jupyter-Core 4.4.0
Ich habe immer noch das Problem unter bokeh == 0.12.10. Vielleicht hat eine Abhängigkeitsänderung das kaputt gemacht? Es könnte für mich sinnvoll sein, auf 0.12.12 zu warten und das zu testen. – Paul
kann ich nicht sagen. Ich habe Ihren Code mit '0.12.10' ausgeführt und es hat wie erwartet funktioniert. – bigreddot