Bokeh 简明教程

Bokeh - Circle Glyphs

figure 对象具有许多使用矢量图形的不同形状(如 circle, rectangle, polygon, 等)的方法,可以进行绘制。

The figure object has many methods using which vectorised glyphs of different shapes such as circle, rectangle, polygon, etc. can, be drawn.

提供以下方法绘制 circle glyphs -

Following methods are available for drawing circle glyphs

circle()

circle() 方法向 figure 添加圆形字形,并需要其中心的 x 和 y 坐标。此外,可以使用诸如 fill_color, line-color, line_width 等参数对其进行配置。

The circle() method adds a circle glyph to the figure and needs x and y coordinates of its center. Additionally, it can be configured with the help of parameters such as fill_color, line-color, line_width etc.

circle_cross()

circle_cross() 方法通过圆心添加带有 “+” 交叉的圆形字形。

The circle_cross() method adds circle glyph with a ‘+’ cross through the center.

circle_x()

circle_x() 方法通过圆心添加带有 “X” 交叉的圆形。

The circle_x() method adds circle with an ‘X’ cross through the center.

Example

以下示例展示了添加到 Bokeh 图形中的各种圆形字形的用法 -

Following example shows use of various circle glyphs added to Bokeh figure −

from bokeh.plotting import figure, output_file, show
plot = figure(plot_width = 300, plot_height = 300)
plot.circle(x = [1, 2, 3], y = [3,7,5], size = 20, fill_color = 'red')
plot.circle_cross(x = [2,4,6], y = [5,8,9], size = 20, fill_color = 'blue',fill_alpha = 0.2, line_width = 2)
plot.circle_x(x = [5,7,2], y = [2,4,9], size = 20, fill_color = 'green',fill_alpha = 0.6, line_width = 2)
show(plot)

Output

circle cross