使用散景滑块与数组

时间:2017-04-27 18:55:28

标签: slider bokeh

第一行还可以,但是......为什么当我更改幻灯片值时没有任何反应?请帮忙! (rotateimg是一个480x360阵列)。似乎update_line函数不起作用......

output_notebook()


TOOLS="pan, box_zoom, reset, save, crosshair"

slider = Slider(start=1, end=360, value=250, step=1)

# Original dataset
x = np.arange(0,len(rotateimg),1)
y = [img[slider.value][i] for i in  xrange(len(x))]

print(len(x))
print(len(y))



# create a new plot with a title and axis labels
p = figure(title="Brillo en una línea de la imagen", x_axis_label='x', y_axis_label='Brillo',tools=TOOLS)
figline = p.line(x, y, line_width=2)

def update_line(attr, old, new):
    x = np.arange(0,len(rotateimg),1)
    new_y = [img[slider.value][i] for i in  xrange(len(x))]

    figline.data_source.data['y'] = new_y


slider.on_change('value', update_line)
layout = row(
    widgetbox(slider),
    p
)

#output_file("slider.html", title="slider.py example")

show(layout)
#

0 个答案:

没有答案