question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to interactively update renderer (i.e. circle, triangle, etc.) size using Bokeh server

See original GitHub issue

I am able to update the color and line width of renderers in Bokeh server, but if I try to update the “size” nothing happens. You can type in a color (black, green, blue, etc) into the color box, and the renderers change color. I have been tweaking the sliders.py example to test this out. The code is below. If you change the glyph.size to glyph.line_width in the update_size method, then the plot does update the line width, but using “size”, nothing happens. I am using Python 2.7.12, Ubuntu 16.04, bokeh server 0.12.5, and Tornado 4.4.2.

A user at stackoverflow did note that if you scrub the sliders, then the size will change, so he felt this was a bug of some sort (https://stackoverflow.com/questions/43577293/unable-to-interactively-update-renderer-i-e-circle-triangle-etc-size-using)

Below is my code:

import numpy as np
from bokeh.io import curdoc
from bokeh.layouts import row, widgetbox
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import Slider, TextInput
from bokeh.plotting import figure

# Set up data
N = 200
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))

# Set up widgets
text = TextInput(title="title", value='my sine wave')
text2 = TextInput(title="size", value='6')
text3 = TextInput(title="color", value='red')
offset = Slider(title="offset", value=0.0, start=-5.0, end=5.0, step=0.1)
amplitude = Slider(title="amplitude", value=1.0, start=-5.0, end=5.0)
phase = Slider(title="phase", value=0.0, start=0.0, end=2*np.pi)
freq = Slider(title="frequency", value=1.0, start=0.1, end=5.1)

# Set up plot
plot = figure(plot_height=400, plot_width=400, title="my sine wave",
              tools="crosshair,pan,reset,save,wheel_zoom",
              x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])

r = plot.circle('x', 'y', source=source, size=int(text2.value), line_alpha=0.6, color = text3.value, legend = 'test')
glyph = r.glyph

# Set up callbacks
def update_title(attrname, old, new):
    plot.title.text = text.value

text.on_change('value', update_title)

def update_size(attrname, old, new):
    glyph.size = int(text2.value)    

text2.on_change('value', update_size)

def update_color(attrname, old, new):
    glyph.fill_color = text3.value

text3.on_change('value', update_color)

def update_data(attrname, old, new):

    # Get the current slider values
    a = amplitude.value
    b = offset.value
    w = phase.value
    k = freq.value

    # Generate the new curve
    x = np.linspace(0, 4*np.pi, N)
    y = a*np.sin(k*x + w) + b

    source.data = dict(x=x, y=y)

for w in [offset, amplitude, phase, freq]:
    w.on_change('value', update_data)

# Set up layouts and add to document
inputs = widgetbox(text, text2, text3, offset, amplitude, phase, freq)
plot.legend.location = "top_left"
plot.legend.click_policy="hide"
curdoc().add_root(row(inputs, plot, width=800))
curdoc().title = "Sliders"

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, Jun 12, 2017

@oxydron I have scheduled this of for the 0.12.7 release (it is too late for the next release which is tomorrow). In the mean time, have you tried updating the .start and .end on an existing range, instead replacing an entire range? I know for certain that this has been demonstrated successfully on many occasions. (Bokeh is a large and complicated library and some use cases are simply more well-established than others at this point. Of course we’d like everything to be perfect but the only thing that can speed up the rate of development at this point is more developers)

If you have tried this and are saying that this approach is not working, please post a complete minimal test case so that it can be investigated.

0reactions
oxydroncommented, Jun 13, 2017

Indeed @bryevdv seems that I can do something with it. I’ve put the change inside the update call, but doesn’t plot right. source: https://pastebin.com/kJbVTEPQ analysis file: https://pastebin.com/VxHuKg9P command: bokeh serve --show filey.py Any help would be appreciated (including on how to not use global vars 👎 )

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to interactively update renderer (i.e. circle, triangle, etc ...
I am able to update the color and line width of renderers in Bokeh server, but if I try to update the "size"...
Read more >
Interactively update renderer (i.e. circle, triangle, etc.) size
Hello, How i can update size of each point selected? I want to have many points with many different size Thanks.
Read more >
figure — Bokeh 2.4.3 Documentation
A subclass of Plot that simplifies plot creation with default axes, grids, tools, etc. Figure objects have many glyph methods that can be...
Read more >
Running a Bokeh server
Bokeh server makes it easy to create interactive web applications that connect front-end UI events to running Python code. Bokeh creates high-level Python ......
Read more >
bokeh.models.markers.Triangle — Bokeh 1.1.0 documentation
Render triangle markers. Example. import numpy as np from bokeh.models import ColumnDataSource, Plot, LinearAxis, Grid from bokeh.models.markers import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found