Bokeh - 矩形、椭圆形和多边形

可以在 Bokeh 图形中渲染矩形、椭圆和多边形。 Figure 类的 rect() 方法 根据中心、宽度和高度的 x 和 y 坐标添加一个矩形字形。 另一方面, square() 方法有 size 参数来决定尺寸。

ellipse() 和 oval() 方法添加一个椭圆和椭圆形字形。 它们使用与具有 x、y、w 和 h 参数的 rect() 相似的签名。 此外,angle 角度参数决定了从水平方向的旋转。

示例

下面的代码展示了不同形状字形方法的使用 −

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)

输出

polygons