[英]Adjust bokeh plot size in Jupyter Notebook
我正在使用散景在 Jupyter Notebook 中繪圖,但我找不到使繪圖更大的方法。 我懷疑它應該很簡單,但我還找不到辦法做到這一點。
我的代碼是(我用它來繪制動態系統):
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)
如果有人感興趣,我使用在調用函數之前定義散景圖形類型來解決它,然后將其傳遞給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
)
這有效!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.