![]() Then it will sort of work by finally showing a plot. ![]() To get it to work first I have to try running it in JupyterLab and see the error that will be like Javascript Error: Error rendering Bokeh model: could not find #9ee3112f-b0fa-478a-86f5-f925a328c52b HTML tag, then stop the kernel, and run it in the classic interface, ignoring the error May also see NameError: name ‘mapper’ is not defined` that pops up the first time or two. HUGE, STRANGE CAVEAT: It is super glitchy though. I place this code in place of your plotting cell. (You may wish to see here & note ipywidgets now need an output widget capturing the output to display.)īelow results in close to what you had and works at some level. So seeing that one here work that seems to use modern ipywidgets practices as evidenced by the use of output_figure = widgets.Output(), I wonder if it could be adapted. Although, oddly that change was enough to get your size-adjusting and title widgets to display, but the plot wouldn’t. However, Bokeh is much different & just switching to interactive as a work-around wasn’t enough, like it was in those other cases. I suspect your issue is related to the issue I think am seeing with ipywidget’s interact() and current MyBinder launches. I note it uses interactive() (see below) and so trying to see if it is adaptable to fix your stuff. Offset_text.There is an interactive Bokeh that presently works in the classic notebook interface in launches from your instance after running %pip install sklearn first: here. ![]() Offset_slider.js_on_change('value', thecallback) now just your basic if statement to handle either case so we can figure out what's being altered (i.e the slider or the text) via the name attribute attached to cb_obj useful: built into CustomJS funcs is the cb_obj variable, which refers to the object that is being altered/used Thecallback = CustomJS(args=dict(source=source,os=offset_slider,ot=offset_text), Offset_text = TextInput(value="0.1", title="offsettext",name='textyboi') Offset_slider = Slider(start=-5, end=5, value=0, step=1, title="Offsetslider",name='slideyboi') #adding "name" attributes to the models can really help identify them later. My solution is to use/abuse the “name” attribute (which is available on all bokeh models AFAIK). The tricky part with making it “one callback” is that you need a way to identify what widget was changed, and then update the other one. That’s totally possible to do (and my solution below does that), but you COULD simplify things by creating two callbacks, one to execute when the slider changes, and one to execute when the text input changes. The second thing is the callback code itself → you are really trying to make the function work for both cases: one) where user changes text input you want the slider to update, and two) where user changes slider you want the text to update. With CustomJS, you don’t need to embed it in a python function, you just assign the callback to the widget via js_on_change. The biggest thing is that you’re mixing up python-callbacks with CustomJS callbacks. Layout = row(plot,column(offset_slider,offset_text)) Offset_text.js_on_change('value', thecallback(offset_text)) Offset_slider.js_on_change('value', thecallback(offset_slider)) ![]() Return CustomJS(args=dict(source=source, offset=offset_type), Offset_text = TextInput(value="0.1", title="offsettext") Offset_slider = Slider(start=-5, end=5, value=0, step=1, title="Offsetslider") Plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6) ![]() Source = ColumnDataSource(data=dict(x=x, y=y)) Hi the situation where I am … import numpy as npįrom bokeh.models import CustomJS, Sliderįrom otting import ColumnDataSource, figure, showįrom import TextInput ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |