初学Bokeh:调整绘图大小【15】跬步
初学Bokeh:调整绘图大小【15】跬步
Bokeh 中的绘图对象具有多种属性,这些属性会影响绘图的外观。
调用 figure() 函数时使用 width 和 height 属性就可以设置绘图的大小:
from bokeh.plotting import figure, show
# prepare some data
# 定义绘图数据
x = [1, 2, 3, 4, 5]
y = [4, 5, 5, 7, 2]
# create a new plot with a specific size
# 创建一个绘图对象
p = figure(
title="Plot sizing example", # 标题
width=350, # 宽度
height=250, # 高度
x_axis_label="x", # x轴标签
y_axis_label="y", # y轴标签
)
# add circle renderer
# 添加一个圆对象,填充色:red,尺寸:15
circle = p.circle(x, y, fill_color="red", size=15)
# show the results
show(p)
与更改现有字体的方法类似,也可以在创建绘图后随时更改绘图的大小:
from bokeh.plotting import figure, show
# prepare some data
# 定义显示数据
x = [1, 2, 3, 4, 5]
y = [4, 5, 5, 7, 2]
# create a new plot with a specific size
# 创建一个绘图对象
p = figure(
title="Plot resizing example", # 标题
width=350, # 宽度
height=250, # 高度
x_axis_label="x", # x轴标签
y_axis_label="y", # y轴标签
)
# change plot size
# 更改绘图尺寸
p.width = 450 # 宽度
p.height = 150 # 高度
# add circle renderer
# 添加一个圆对象,填充色:red,尺寸:15
circle = p.circle(x, y, fill_color="red", size=15)
# show the results
show(p)
标签:
python绘图
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!