Python 中的 Bokeh.plotting.figure.circle() 函数详解

Bokeh 是 Python 中一个强大的数据可视化库,它能让我们生成高性能的交互式图表。我们可以将结果输出到多种媒介,例如 Notebook、HTML 文件或服务器端。Figure 类可以帮助我们创建一个新的绘图对象。作为 Plot 的子类,它通过提供默认的坐标轴、网格和工具等,极大地简化了绘图的过程。

在 bokeh 库的 plotting 模块中,circle() 函数用于配置并向当前的 Figure 对象中添加圆形标记。

> 语法: circle(x, y, , angle=0.0, angleunits=‘rad‘, fillalpha=1.0, fillcolor=‘gray‘, linealpha=1.0, linecap=‘butt‘, linecolor=‘black‘, linedash=[], linedashoffset=0, linejoin=‘bevel‘, linewidth=1, name=None, radius=None, radiusdimension=‘x‘, radius_units=‘data‘, size=4, tags=[], *kwargs)

>

> 参数: 该方法接受以下参数,我们将详细描述它们:

>

> – x: 此参数表示标记中心的 x 坐标。

> – y: 此参数表示标记中心的 y 坐标。

> – angle: 此参数用于旋转标记的角度。

> – fill_alpha: 此参数表示标记的填充透明度。

> – fill_color: 此参数表示标记的填充颜色。

> – line_alpha: 此参数表示标记线条的透明度,默认值为 1.0。

> – line_cap: 此参数表示标记线条的端点样式,默认值为 ‘butt‘。

> – line_color: 此参数表示标记线条的颜色,默认值为黑色 (‘black‘)。

> – line_dash: 此参数表示标记线条的虚线样式,默认值为 []。

> – linedashoffset: 此参数表示标记线条虚线偏移量,默认值为 0。

> – line_join: 此参数表示标记线条的连接样式,默认值为 ‘bevel‘。

> – line_width: 此参数表示标记线条的宽度,默认值为 1。

> – mode: 此参数可以是三个值之一:["before", "after", "center"]。

> – name: 此参数是为此模型提供的用户自定义名称。

> – tags: 此参数是为此模型提供的用户自定义值。

> – radius: 此参数是圆形标记的半径值。

> – radius_dimension: 此参数用于指定测量圆形半径所沿的维度。

> – size: 此参数是标记的大小(直径),以屏幕空间单位为单位。

>

>

> 其他参数: 这些参数是 kwargs,描述如下:

>

> – alpha: 此参数用于一次性设置所有 alpha 关键字参数。

> – color: 此参数用于一次性设置所有颜色关键字参数。

> – legend_field: 此参数是数据源中应用于分组的列名。

> – legend_group: 此参数是数据源中应用于分组的列名。

> – legend_label: 此参数表示图例条目将完全使用此处提供的文本进行标记。

> – muted: 此参数包含布尔值。

> – name: 此参数是可选的用户自定义名称,用于附加到渲染器。

> – source: 此参数是用户提供的数据源。

> – view: 此参数是用于过滤数据源的视图。

> – visible: 此参数包含布尔值。

> – xrangename: 此参数是用于映射 x 坐标的额外范围的名称。

> – yrangename: 此参数是用于映射 y 坐标的额外范围的名称。

> – level: 此参数指定此图形的渲染级别顺序。

>

> 返回值: 此方法返回 GlyphRenderer 值。

下面的例子向我们展示了 bokeh.plotting.figure.circle() 函数在实际应用中的效果:

示例 1:

Python3

# Implementation of bokeh function
 
import numpy as np 
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, color ="green", alpha = 0.6)
 
show(plot)

输出结果:

!image

示例 2:

Python3

# Implementation of bokeh function
 
import numpy as np 
from bokeh.plotting import figure, output_file, show
 
x = [1, 2, 3, 4, 5]
y = [6, 7, 8, 7, 3]

output_file("geeksforgeeks.html")

p = figure(plot_width = 300, plot_height = 300)

# add both a line and circles on the 
# same plot
p.line(x, y, line_width = 2)
p.circle(x, y, fill_color ="red", 
         line_color ="green", size = 8)

show(p)

输出结果:

![image](https://media.geeksforgeeks.org/wp-conten

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。如需转载,请注明文章出处豆丁博客和来源网址。https://shluqu.cn/28006.html
点赞
0.00 平均评分 (0% 分数) - 0