Bokeh - 矩形、橢圓和多邊形



可以在 Bokeh 圖形中呈現矩形、橢圓和多邊形。Figure 類的rect() 方法基於中心、寬度和高度的 x 和 y 座標新增一個矩形字型。另一方面,square() 方法具有大小引數來確定維度。

ellipse() 和 oval() 方法新增一個橢圓和橢圓字型。它們使用與 rect() 相似的簽名,具有 x、y、w 和 h 引數。此外,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
廣告