互联网的大家好,
因此,我尝试进行简单的交互式可视化,在其中可以使用滑动条使用python和bokeh更改绘图上某些点的半径。但是,当我尝试进行更新功能时,似乎收到一条错误消息,内容为:500内部服务器错误如果有人知道我应该对代码进行哪些更改,那么我想知道。
# imports
from bokeh.io import push_notebook, show, output_notebook
from bokeh.server.server import Server
from bokeh.application import Application
from bokeh.application.handlers.function import FunctionHandler
from bokeh.layouts import column
from bokeh.models import Slider
from bokeh.plotting import figure
output_notebook()
# Webpage function, this function will be called upon creating the webpage
def make_page(doc):
#source = ColumnDataSource(data=dict(radius=20))
size=20
def update(attr, old, new):
s = new
radius = s
size.data = dict(radius)
plot = figure(plot_width=400, plot_height=400)
plot.circle([1,2], [4,8], size = size, color='blue', alpha=0.5);
slider = Slider(start=0, end=30, value=20, step=1, title="Number")
slider.on_change(update)
# adding the slider and plot to the document shown on the webpage
# all elements of the webpage have to be added below
doc.add_root(column(slider, plot))
# creating the application and running the server local, (http://localhost:5000), port 5000 can be changed
apps = {'/': Application(FunctionHandler(make_page))}
server = Server(apps, port=5000)
server.start()
提前感谢!
如果从控制台运行Jupyter笔记本,则应该看到完整的堆栈跟踪,并带有确切的错误。
[没有Minimal, Reproducible Example很难说出任何东西,但似乎您正在尝试从dict
创建一个radius
,但在Python中无法使用。