push_notebook 在 Google Collab Jupyter Notebook 中不起作用
push_notebook does not work in Google Collab Jupyter Notebook
我在 Google 协作中使用散景。我想知道是否有人在 Google Collab Jupyter notebook 中使用过 push_notebook。我正在尝试 运行 在 Google Collab 上遵循 Jupiter Notebook 中的代码,但它卡在了 push_notebook() 命令
from ipywidgets import interact
import numpy as np
from bokeh.io import push_notebook,show,output_notebook
from bokeh.plotting import figure
output_notebook()
x=np.linspace(0,2*np.pi,2000)
y=np.sin(x)
p=figure(title="ff",plot_height=300,plot_width=600,y_range=(-5,5))
r=p.line(x,y,color="red",line_width=2)
def update(f,w=1,A=1,phi=0):
print("fff")
if f== "sin":func=np.sin
if f== "sin":func=np.sin
elif f=="cos":func =np.cos
elif f== "tan":func=np.tan
r.data_source.data['y']=A*func(w*x+phi)
push_notebook()
show(p,notebook_handle=True)
interact(update,f=["sin","cos","tan"],w=(0,100),A=(1,5),phi=(0,20,0.1))
任何人都可以提出代码中的错误以及它是如何出现的 运行 Google Collab.
push_notebook
不能也不能在 Google Collab 上工作,因为 Google 的笔记本实现不允许打开必要的 websocket 连接。对此无能为力 until/unless Google 最终做出改变。
我在 Google 协作中使用散景。我想知道是否有人在 Google Collab Jupyter notebook 中使用过 push_notebook。我正在尝试 运行 在 Google Collab 上遵循 Jupiter Notebook 中的代码,但它卡在了 push_notebook() 命令
from ipywidgets import interact
import numpy as np
from bokeh.io import push_notebook,show,output_notebook
from bokeh.plotting import figure
output_notebook()
x=np.linspace(0,2*np.pi,2000)
y=np.sin(x)
p=figure(title="ff",plot_height=300,plot_width=600,y_range=(-5,5))
r=p.line(x,y,color="red",line_width=2)
def update(f,w=1,A=1,phi=0):
print("fff")
if f== "sin":func=np.sin
if f== "sin":func=np.sin
elif f=="cos":func =np.cos
elif f== "tan":func=np.tan
r.data_source.data['y']=A*func(w*x+phi)
push_notebook()
show(p,notebook_handle=True)
interact(update,f=["sin","cos","tan"],w=(0,100),A=(1,5),phi=(0,20,0.1))
任何人都可以提出代码中的错误以及它是如何出现的 运行 Google Collab.
push_notebook
不能也不能在 Google Collab 上工作,因为 Google 的笔记本实现不允许打开必要的 websocket 连接。对此无能为力 until/unless Google 最终做出改变。