我在 Jupyter 上写了这段代码,但是从 randomx和计算结果后y,Bokeh Graph 没有显示数据?
我怎样才能修改x,y以便我可以向散景图显示 x 和 y?
import random
import math
import numpy as np
from functools import partial
from bokeh.io import show, output_notebook
from bokeh.layouts import row
from bokeh.plotting import figure
from bokeh.embed import notebook_div
from bokeh.models import ColumnDataSource
import plotly.plotly as py
from plotly.graph_objs import *
random.seed(10)
output_notebook(hide_banner=True)
n_step = 1000
n_parts = 10
sigma = 1.
mu = 0.
x = np.zeros((n_step, n_parts))
y = np.zeros((n_step, n_parts))
for i in range(n_step - 1):
x[i + 1, :] = x[i, :] + np.random.normal(mu, sigma, (1, n_parts))
y[i + 1, :] = y[i, :] + np.random.normal(mu, sigma, (1, n_parts))
output_notebook()
x = [x]
y = [y]
source = ColumnDataSource(data=dict(x=x, y=y))
p = figure(title='Sample',plot_width=800, plot_height=800)
p.line(x='x' ,y='y' ,source = source)
show(p)
烙印99
相关分类