Bokeh 矩形、椭圆形和多边形


可以渲染 矩形、椭圆和多边形 在Bokeh 图中。这 rect() 方法 Figure 类添加了一个基于中心、宽度和高度的 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)
polygons