Bokeh 简明教程

Bokeh - Rectangle, Oval and Polygon

可以在 Bokeh 图形中渲染 rectangle, ellipse and polygons 。Figure 类的 rect() method 基于中心的 x 和 y 坐标、宽度和高度添加矩形图形。另一方面,square() 方法具有大小参数来确定尺寸。

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

Example

以下代码显示了不同 shape glyph methods 的用法 −

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)

Output

polygons