可以在散景图中渲染矩形、椭圆和多边形。Figure 类的 rect()
方法根据中心、宽度和高度的 x 和 y 坐标添加一个矩形字形。square()
方法具有 size
参数来决定尺寸。ellipse()
和 oval()
方法添加了一个椭圆和椭圆字形。它们使用与具有 x、y、w 和 h 参数的 rect()
类似的签名。此外,角度参数确定从水平方向旋转。
例子
以下代码显示了不同形状字形方法的使用 -
from bokeh.plotting import figure, output_file, show
fig = figure(plot_width = 300, plot_height = 300)
fig.rect(x = 10,y = 10,width = 100, height = 50, width_units = 'screen', height_units = 'screen')
fig.square(x = 2,y = 3,size = 80, color = 'red')
fig.ellipse(x = 7,y = 6, width = 30, height = 10, fill_color = None, line_width = 2)
fig.oval(x = 6,y = 6,width = 2, height = 1, angle = -0.4)
show(fig)
运行结果: