[英]Adjust bokeh plot size in Jupyter Notebook
I'm using bokeh to plot in a Jupyter Notebook, but I can't find a way to make the plot larger.我正在使用散景在 Jupyter Notebook 中绘图,但我找不到使绘图更大的方法。 I suspect it should be simple but I couldn't find a way to do this yet.
我怀疑它应该很简单,但我还找不到办法做到这一点。
My code is (I'm using it to plot a dynamical system):我的代码是(我用它来绘制动态系统):
import numpy as np
import scipy.integrate
import biocircuits
import bokeh.io
import bokeh.plotting
from bokeh.plotting import figure
import panel as pn
pn.extension()
bokeh.io.output_notebook()
def dX_dt(X, Y, mu):
return Y * ( mu - 2*X )
def dY_dt(X, Y, mu):
return -mu*X + X**2 - Y**2 + 1
def ode_rhs(x, t, mu):
"""Compute right-hand-side of pair of ODEs."""
X, Y = x
return np.array(
[
dX_dt(X, Y, mu),
dY_dt(X, Y, mu),
]
)
# Specify parameters
mu = 3.0
# Package for the integrating function
params_X = (mu,)
params_Y = (mu,)
# Plotting the phase portrait
X_range = [-3, 3]
Y_range = [-3, 3]
p = figure(plot_height=1000, plot_width=1000)
p = biocircuits.phase_portrait(
dX_dt,
dY_dt,
X_range,
Y_range,
params_X,
params_Y,
x_axis_label="X",
y_axis_label="Y",
color="#e6ab02",
plot_width=1000,
height=1000
)
if mu < 2:
p.circle(*np.array([ mu/2 , np.sqrt(1 - (mu/2)**2) ]), color='black', size=10)
p.circle(*np.array([ mu/2 , -np.sqrt(1 - (mu/2)**2) ]), color='white', line_color='black', line_width=2, size=10)
if mu > 2:
p.circle(*np.array([ mu/2 + np.sqrt((mu/2)**2 - 1), 0 ]), color='black', size=10)
p.circle(*np.array([ mu/2 - np.sqrt((mu/2)**2 - 1), 0 ]), color='white', line_color='black', line_width=2, size=10)
p.title.text = "Kd = 1, β₀ = 1"
bokeh.io.show(p)
In case someone will be interested, I solved it using defining a bokeh figure type before calling the function and then pass it to the biocircuits.phase_portrait
function:如果有人感兴趣,我使用在调用函数之前定义散景图形类型来解决它,然后将其传递给
biocircuits.phase_portrait
函数:
p = figure(plot_height=550, plot_width=700, x_axis_label="X", y_axis_label="Y",
title="μ = 3")
p = biocircuits.phase_portrait(
dX_dt,
dY_dt,
X_range,
Y_range,
params_X,
params_Y,
x_axis_label="X",
y_axis_label="Y",
color="#e6ab02",
p=p
)
This worked!这有效!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.