坐标轴#
为可以添加到Bokeh图中的各种轴提供指导渲染器
- class Axis(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
基础类:
GuideRenderer一个基类,定义了所有轴类型的公共属性。
注意
这是一个抽象基类,用于帮助组织Bokeh模型类型的层次结构。单独实例化它没有用处。
JSON Prototype
{ "axis_label": null, "axis_label_align": "center", "axis_label_orientation": "parallel", "axis_label_standoff": 5, "axis_label_text_align": "left", "axis_label_text_alpha": 1.0, "axis_label_text_baseline": "bottom", "axis_label_text_color": "#444444", "axis_label_text_font": "helvetica", "axis_label_text_font_size": "13px", "axis_label_text_font_style": "italic", "axis_label_text_line_height": 1.2, "axis_label_text_outline_color": null, "axis_line_alpha": 1.0, "axis_line_cap": "butt", "axis_line_color": "black", "axis_line_dash": [], "axis_line_dash_offset": 0, "axis_line_join": "bevel", "axis_line_width": 1, "background_fill_alpha": 1.0, "background_fill_color": null, "bounds": "auto", "context_menu": null, "coordinates": null, "css_classes": [], "css_variables": { "type": "map" }, "dimension": "auto", "face": "auto", "fixed_location": null, "formatter": { "name": "unset", "type": "symbol" }, "group": null, "id": "p54492", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "guide", "major_label_orientation": "horizontal", "major_label_overrides": { "type": "map" }, "major_label_policy": { "id": "p54493", "name": "AllLabels", "type": "object" }, "major_label_standoff": 5, "major_label_text_align": "center", "major_label_text_alpha": 1.0, "major_label_text_baseline": "alphabetic", "major_label_text_color": "#444444", "major_label_text_font": "helvetica", "major_label_text_font_size": "11px", "major_label_text_font_style": "normal", "major_label_text_line_height": 1.2, "major_label_text_outline_color": null, "major_tick_in": 2, "major_tick_line_alpha": 1.0, "major_tick_line_cap": "butt", "major_tick_line_color": "black", "major_tick_line_dash": [], "major_tick_line_dash_offset": 0, "major_tick_line_join": "bevel", "major_tick_line_width": 1, "major_tick_out": 6, "minor_tick_in": 0, "minor_tick_line_alpha": 1.0, "minor_tick_line_cap": "butt", "minor_tick_line_color": "black", "minor_tick_line_dash": [], "minor_tick_line_dash_offset": 0, "minor_tick_line_join": "bevel", "minor_tick_line_width": 1, "minor_tick_out": 4, "name": null, "propagate_hover": false, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "ticker": { "name": "unset", "type": "symbol" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
- axis_label_orientation = 'parallel'#
- Type:
轴标签文本应该朝向的方向。如果提供了一个数字,文本的角度将从水平方向测量。
- axis_label_text_baseline = 'bottom'#
- Type:
轴标签的文本基线。
- axis_line_dash = []#
- Type:
轴线的虚线样式。
- bounds = 'auto'#
-
渲染轴的边界。如果未设置,轴将在给定维度上跨越整个绘图。
- css_variables = {}#
-
允许定义动态计算的CSS变量。
例如,这可以用于协调canvas渲染器和/或视觉效果与基于HTML的UI元素之间的定位和样式。
这里定义的变量等同于在CSS样式表中的
:host { ... }下设置相同的变量。注意
此属性是实验性的,可能会随时更改。
- dimension = 'auto'#
-
这允许在支持此功能的上下文中覆盖推断的尺寸。当轴用作框架轴时,此属性无效。
注意
此属性是实验性的,可能会随时更改。
- fixed_location = None#
-
设置为指定一个固定的坐标位置来绘制轴。刻度和主要标签的方向由轴所属的侧面板决定。
注意
当坐标轴位于中央绘图区域内的固定位置时,坐标轴标签会被隐藏。
- formatter = Undefined#
- Type:
用于格式化刻度视觉外观的
TickFormatter。
- group = None#
- Type:
注意
此属性是实验性的,可能会随时更改。
- level = 'guide'#
- Type:
指定绘制此渲染器的层级。
- major_label_orientation = 'horizontal'#
- Type:
主要标签文本的方向应该如何确定。如果提供了一个数字,文本的角度将从水平方向测量。
- major_label_overrides = {}#
-
为特定的刻度位置提供明确的刻度标签值,这些值会覆盖正常的格式化。
- major_label_policy = AllLabels(id='p54564', ...)#
- Type:
Instance(LabelingPolicy)
允许过滤掉标签,例如整理标签以避免重叠。
- major_label_text_baseline = 'alphabetic'#
- Type:
主要刻度标签的文本基线。
- major_tick_line_dash = []#
- Type:
主要刻度线的虚线样式。
- minor_tick_line_dash = []#
- Type:
次要刻度线的虚线样式。
- name = None#
-
此模型的任意用户提供的名称。
在查询文档以检索特定Bokeh模型时,此名称可能很有用。
>>> plot.circle([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
注意
对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。
- stylesheets = []#
- Type:
用于底层DOM元素的附加样式表。
请注意,所有Bokeh的组件都使用影子DOM,因此任何包含的样式表都必须反映这一点,例如使用
:hostCSS伪选择器来访问根DOM元素。
- syncable = True#
- Type:
指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为
False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。注意
将此属性设置为
False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。
- tags = []#
- Type:
一个可选的任意用户提供的值列表,用于附加到此模型。
在查询文档以检索特定Bokeh模型时,这些数据可能很有用:
>>> r = plot.circle([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过
CustomJS回调等方式访问。注意
对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。
- ticker = Undefined#
-
用于计算轴组件位置的Ticker。
该属性也可以传递一系列浮点数作为创建和配置
FixedTicker的简写,例如以下代码from bokeh.plotting import figure p = figure() p.xaxis.ticker = [10, 20, 37.4]
等同于:
from bokeh.plotting import figure from bokeh.models import FixedTicker p = figure() p.xaxis.ticker = FixedTicker(ticks=[10, 20, 37.4])
- apply_theme(property_values: dict[str, Any]) None#
应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。
传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和
HasProps实例都不应修改它)。- Parameters:
property_values (dict) – 用于替换默认值的主题值
- Returns:
无
- classmethod clear_extensions() None#
清除当前定义的所有自定义扩展。
序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。
- classmethod descriptors() list[PropertyDescriptor[Any]]#
属性描述符的列表,按定义的顺序排列。
- equals(other: HasProps) bool#
模型的结构相等性。
- Parameters:
其他 (HasProps) – 要比较的其他实例
- Returns:
如果属性在结构上相等,则为True,否则为False
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
使用JavaScript链接两个Bokeh模型属性。
这是一个便捷的方法,简化了添加一个
CustomJS回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。- Parameters:
在版本1.1中添加
- Raises:
示例
这段代码使用了
js_link:select.js_link('value', plot, 'sizing_mode')
等同于以下内容:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
这相当于:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
- js_on_change(event: str, *callbacks: JSChangeCallback) None#
将一个
CustomJS回调附加到任意的BokehJS模型事件。在BokehJS方面,模型属性的更改事件具有
"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到
ColumnDataSource时运行回调,可以在源上使用"stream"事件:source.js_on_change('streaming', callback)
- classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#
在类上找到Bokeh属性的
PropertyDescriptor,给定属性名称。- Parameters:
- Returns:
名为
name的属性的描述符- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
在此对象上添加一个回调,当
attr发生变化时触发。- Parameters:
attr (str) – 此对象上的一个属性名称
*callbacks (callable) – 要注册的回调函数
- Returns:
无
示例
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#
当此模型上发生指定事件时运行回调
并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。
- classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#
收集此类的属性名称。
警告
在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在
list中。- Returns:
属性名称
- classmethod properties_with_refs() dict[str, Property[Any]]#
收集此类上所有具有引用的属性的名称。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
- properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
收集一个将属性名称映射到其值的字典。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。
- query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
使用谓词查询
HasProps实例的属性值。
- select(selector: SelectorType) Iterable[Model]#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
- Returns:
序列[模型]
- select_one(selector: SelectorType) Model | None#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like
- Returns:
模型
- set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#
从JSON设置此对象的属性值。
- Parameters:
name (str) – 要设置的属性名称
value (JSON-value) – 要设置给属性的值
setter (ClientSession 或 ServerSession 或 None, 可选) –
这用于防止对Bokeh应用程序的“回旋镖”更新。
在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。
- Returns:
无
- set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#
使用指定的属性/值更新来更新与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
更新 (dict)
- Returns:
无
- themed_values() dict[str, Any] | None#
获取任何主题提供的覆盖。
结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回
None。- Returns:
字典或无
- to_serializable(serializer: Serializer) ObjectRefRep#
将此对象转换为可序列化的表示形式。
- trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
- class CategoricalAxis(*args: Any, id: ID | None = None, **kwargs: Any)[源代码]#
基础类:
Axis一个显示分类范围的刻度和标签的轴。
CategoricalAxis可以处理最多两级嵌套的因子范围,包括在顶级因子组之间绘制分隔线。JSON Prototype
{ "axis_label": null, "axis_label_align": "center", "axis_label_orientation": "parallel", "axis_label_standoff": 5, "axis_label_text_align": "left", "axis_label_text_alpha": 1.0, "axis_label_text_baseline": "bottom", "axis_label_text_color": "#444444", "axis_label_text_font": "helvetica", "axis_label_text_font_size": "13px", "axis_label_text_font_style": "italic", "axis_label_text_line_height": 1.2, "axis_label_text_outline_color": null, "axis_line_alpha": 1.0, "axis_line_cap": "butt", "axis_line_color": "black", "axis_line_dash": [], "axis_line_dash_offset": 0, "axis_line_join": "bevel", "axis_line_width": 1, "background_fill_alpha": 1.0, "background_fill_color": null, "bounds": "auto", "context_menu": null, "coordinates": null, "css_classes": [], "css_variables": { "type": "map" }, "dimension": "auto", "face": "auto", "fixed_location": null, "formatter": { "id": "p54643", "name": "CategoricalTickFormatter", "type": "object" }, "group": null, "group_label_orientation": "parallel", "group_text_align": "left", "group_text_alpha": 1.0, "group_text_baseline": "bottom", "group_text_color": "grey", "group_text_font": "helvetica", "group_text_font_size": "11px", "group_text_font_style": "bold", "group_text_line_height": 1.2, "group_text_outline_color": null, "id": "p54641", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "guide", "major_label_orientation": "horizontal", "major_label_overrides": { "type": "map" }, "major_label_policy": { "id": "p54644", "name": "AllLabels", "type": "object" }, "major_label_standoff": 5, "major_label_text_align": "center", "major_label_text_alpha": 1.0, "major_label_text_baseline": "alphabetic", "major_label_text_color": "#444444", "major_label_text_font": "helvetica", "major_label_text_font_size": "11px", "major_label_text_font_style": "normal", "major_label_text_line_height": 1.2, "major_label_text_outline_color": null, "major_tick_in": 2, "major_tick_line_alpha": 1.0, "major_tick_line_cap": "butt", "major_tick_line_color": "black", "major_tick_line_dash": [], "major_tick_line_dash_offset": 0, "major_tick_line_join": "bevel", "major_tick_line_width": 1, "major_tick_out": 6, "minor_tick_in": 0, "minor_tick_line_alpha": 1.0, "minor_tick_line_cap": "butt", "minor_tick_line_color": "black", "minor_tick_line_dash": [], "minor_tick_line_dash_offset": 0, "minor_tick_line_join": "bevel", "minor_tick_line_width": 1, "minor_tick_out": 4, "name": null, "propagate_hover": false, "separator_line_alpha": 1.0, "separator_line_cap": "butt", "separator_line_color": "lightgrey", "separator_line_dash": [], "separator_line_dash_offset": 0, "separator_line_join": "bevel", "separator_line_width": 2, "styles": { "type": "map" }, "stylesheets": [], "subgroup_label_orientation": "parallel", "subgroup_text_align": "left", "subgroup_text_alpha": 1.0, "subgroup_text_baseline": "bottom", "subgroup_text_color": "#444444", "subgroup_text_font": "helvetica", "subgroup_text_font_size": "11px", "subgroup_text_font_style": "bold", "subgroup_text_line_height": 1.2, "subgroup_text_outline_color": null, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "ticker": { "id": "p54642", "name": "CategoricalTicker", "type": "object" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
- axis_label_orientation = 'parallel'#
- Type:
轴标签文本应该朝向的方向。如果提供了一个数字,文本的角度将从水平方向测量。
- axis_label_text_baseline = 'bottom'#
- Type:
轴标签的文本基线。
- axis_line_dash = []#
- Type:
轴线的虚线样式。
- bounds = 'auto'#
-
渲染轴的边界。如果未设置,轴将在给定维度上跨越整个绘图。
- css_variables = {}#
-
允许定义动态计算的CSS变量。
例如,这可以用于协调canvas渲染器和/或视觉效果与基于HTML的UI元素之间的定位和样式。
这里定义的变量等同于在CSS样式表中的
:host { ... }下设置相同的变量。注意
此属性是实验性的,可能会随时更改。
- dimension = 'auto'#
-
这允许在支持此功能的上下文中覆盖推断的尺寸。当轴用作框架轴时,此属性无效。
注意
此属性是实验性的,可能会随时更改。
- fixed_location = None#
-
设置为指定一个固定的坐标位置来绘制轴。刻度和主要标签的方向由轴所属的侧面板决定。
注意
当坐标轴位于中央绘图区域内的固定位置时,坐标轴标签会被隐藏。
- formatter = CategoricalTickFormatter(id='p54765', ...)#
- Type:
用于格式化刻度视觉外观的
TickFormatter。
- group = None#
- Type:
注意
此属性是实验性的,可能会随时更改。
- group_label_orientation = 'parallel'#
- Type:
组标签文本应该朝向哪个方向。
如果提供了一个数字,文本的角度将从水平方向测量。
此属性始终适用于最外层嵌套中的因素。 如果分类因素列表是扁平的(即没有嵌套),则此属性无效。
- group_text_align = 'left'#
-
分组类别标签的文本对齐方式。
此属性始终适用于最外层嵌套中的因素。 如果分类因素列表是扁平的(即没有嵌套),则此属性无效。
- group_text_baseline = 'bottom'#
- Type:
分组分类标签的文本基线。
此属性始终适用于最外层嵌套中的因素。 如果分类因素列表是扁平的(即没有嵌套),则此属性无效。
- group_text_color = 'grey'#
-
分组分类标签的文本颜色。
此属性始终适用于最外层嵌套中的因素。 如果分类因素列表是扁平的(即没有嵌套),则此属性无效。
- group_text_font = 'helvetica'#
- Type:
分组类别标签的文本字体。
此属性始终适用于最外层嵌套中的因素。 如果分类因素列表是扁平的(即没有嵌套),则此属性无效。
- group_text_font_size = '11px'#
- Type:
分组类别标签的文本字体大小。
此属性始终适用于最外层嵌套中的因素。 如果分类因素列表是扁平的(即没有嵌套),则此属性无效。
- group_text_font_style = 'bold'#
-
分组类别标签的文本字体样式。
此属性始终适用于最外层嵌套中的因素。 如果分类因素列表是扁平的(即没有嵌套),则此属性无效。
- group_text_line_height = 1.2#
- Type:
分组分类标签的文本行高。
此属性始终适用于最外层嵌套中的因素。 如果分类因素列表是扁平的(即没有嵌套),则此属性无效。
- group_text_outline_color = None#
-
分组分类标签的文本轮廓颜色。
此属性始终适用于最外层嵌套级别的因子。 如果分类因子列表是扁平的(即没有嵌套),则此属性无效。
- level = 'guide'#
- Type:
指定绘制此渲染器的层级。
- major_label_orientation = 'horizontal'#
- Type:
主要标签文本的方向应该如何确定。如果提供了一个数字,文本的角度将从水平方向测量。
- major_label_overrides = {}#
-
为特定的刻度位置提供明确的刻度标签值,这些值会覆盖正常的格式化。
- major_label_policy = AllLabels(id='p54826', ...)#
- Type:
Instance(LabelingPolicy)
允许过滤掉标签,例如整理标签以避免重叠。
- major_label_text_baseline = 'alphabetic'#
- Type:
主要刻度标签的文本基线。
- major_tick_line_dash = []#
- Type:
主要刻度线的虚线样式。
- minor_tick_line_dash = []#
- Type:
次要刻度线的虚线样式。
- name = None#
-
此模型的任意用户提供的名称。
在查询文档以检索特定Bokeh模型时,此名称可能很有用。
>>> plot.circle([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
注意
对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。
- separator_line_dash = []#
- Type:
顶级分类组之间的分隔线的虚线样式。
此属性始终适用于最外层嵌套中的因素。
- stylesheets = []#
- Type:
用于底层DOM元素的附加样式表。
请注意,所有Bokeh的组件都使用影子DOM,因此任何包含的样式表都必须反映这一点,例如使用
:hostCSS伪选择器来访问根DOM元素。
- subgroup_label_orientation = 'parallel'#
- Type:
子组标签文本应该朝向哪个方向。
如果提供了一个数字,文本的角度将从水平方向测量。
此属性始终适用于嵌套中间层的因子。 如果分类因子列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_align = 'left'#
-
子组分类标签的文本对齐方式。
此属性始终适用于嵌套中间级别的因素。 如果分类因素列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_alpha = 1.0#
- Type:
子组分类标签的文本alpha。
此属性始终适用于嵌套中间级别的因子。 如果分类因子列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_baseline = 'bottom'#
- Type:
子组分类标签的文本基线。
此属性始终适用于嵌套中间级别的因子。 如果分类因子列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_color = '#444444'#
-
子组分类标签的文本颜色。
此属性始终适用于嵌套中间级别的因子。 如果分类因子列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_font = 'helvetica'#
- Type:
子组分类标签的文本字体。
此属性始终适用于嵌套中间级别的因子。 如果分类因子列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_font_size = '11px'#
- Type:
子组分类标签的文本字体大小。
此属性始终适用于嵌套中间级别的因素。 如果分类因素列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_font_style = 'bold'#
-
子组分类标签的文本字体样式。
此属性始终适用于嵌套中间级别的因素。 如果分类因素列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_line_height = 1.2#
- Type:
子组分类标签的文本行高。
此属性始终适用于嵌套中间级别的因素。 如果分类因素列表仅具有零级或一级嵌套, 则此属性无效。
- subgroup_text_outline_color = None#
-
子组分类标签的文本轮廓颜色。
此属性始终适用于嵌套中间级别的因素。 如果分类因素列表仅具有零级或一级嵌套, 则此属性无效。
- syncable = True#
- Type:
指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为
False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。注意
将此属性设置为
False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。
- tags = []#
- Type:
一个可选的任意用户提供的值列表,用于附加到此模型。
在查询文档以检索特定Bokeh模型时,这些数据可能很有用:
>>> r = plot.circle([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过
CustomJS回调等方式访问。注意
对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。
- ticker = CategoricalTicker(id='p55035', ...)#
-
用于计算轴组件位置的Ticker。
该属性也可以传递一系列浮点数作为创建和配置
FixedTicker的简写,例如以下代码from bokeh.plotting import figure p = figure() p.xaxis.ticker = [10, 20, 37.4]
等同于:
from bokeh.plotting import figure from bokeh.models import FixedTicker p = figure() p.xaxis.ticker = FixedTicker(ticks=[10, 20, 37.4])
- apply_theme(property_values: dict[str, Any]) None#
应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。
传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和
HasProps实例都不应修改它)。- Parameters:
property_values (dict) – 用于替换默认值的主题值
- Returns:
无
- classmethod clear_extensions() None#
清除当前定义的所有自定义扩展。
序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。
- classmethod descriptors() list[PropertyDescriptor[Any]]#
属性描述符的列表,按定义的顺序排列。
- equals(other: HasProps) bool#
模型的结构相等性。
- Parameters:
其他 (HasProps) – 要比较的其他实例
- Returns:
如果属性在结构上相等,则为True,否则为False
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
使用JavaScript链接两个Bokeh模型属性。
这是一个便捷的方法,简化了添加一个
CustomJS回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。- Parameters:
在版本1.1中添加
- Raises:
示例
这段代码使用了
js_link:select.js_link('value', plot, 'sizing_mode')
等同于以下内容:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
这相当于:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
- js_on_change(event: str, *callbacks: JSChangeCallback) None#
将一个
CustomJS回调附加到任意的BokehJS模型事件。在BokehJS方面,模型属性的更改事件具有
"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到
ColumnDataSource时运行回调,可以在源上使用"stream"事件:source.js_on_change('streaming', callback)
- classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#
在类上找到Bokeh属性的
PropertyDescriptor,给定属性名称。- Parameters:
- Returns:
名为
name的属性的描述符- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
在此对象上添加一个回调,当
attr发生变化时触发。- Parameters:
attr (str) – 此对象上的一个属性名称
*callbacks (callable) – 要注册的回调函数
- Returns:
无
示例
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#
当此模型上发生指定事件时运行回调
并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。
- classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#
收集此类的属性名称。
警告
在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在
list中。- Returns:
属性名称
- classmethod properties_with_refs() dict[str, Property[Any]]#
收集此类上所有具有引用的属性的名称。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
- properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
收集一个将属性名称映射到其值的字典。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。
- query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
使用谓词查询
HasProps实例的属性值。
- select(selector: SelectorType) Iterable[Model]#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
- Returns:
序列[模型]
- select_one(selector: SelectorType) Model | None#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like
- Returns:
模型
- set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#
从JSON设置此对象的属性值。
- Parameters:
name (str) – 要设置的属性名称
value (JSON-value) – 要设置给属性的值
setter (ClientSession 或 ServerSession 或 None, 可选) –
这用于防止对Bokeh应用程序的“回旋镖”更新。
在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。
- Returns:
无
- set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#
使用指定的属性/值更新来更新与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
更新 (dict)
- Returns:
无
- themed_values() dict[str, Any] | None#
获取任何主题提供的覆盖。
结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回
None。- Returns:
字典或无
- to_serializable(serializer: Serializer) ObjectRefRep#
将此对象转换为可序列化的表示形式。
- trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
- class ContinuousAxis(*args: Any, id: ID | None = None, **kwargs: Any)[源代码]#
基础类:
Axis所有数值型、非分类轴类型的基础类。
注意
这是一个抽象基类,用于帮助组织Bokeh模型类型的层次结构。单独实例化它没有用处。
JSON Prototype
{ "axis_label": null, "axis_label_align": "center", "axis_label_orientation": "parallel", "axis_label_standoff": 5, "axis_label_text_align": "left", "axis_label_text_alpha": 1.0, "axis_label_text_baseline": "bottom", "axis_label_text_color": "#444444", "axis_label_text_font": "helvetica", "axis_label_text_font_size": "13px", "axis_label_text_font_style": "italic", "axis_label_text_line_height": 1.2, "axis_label_text_outline_color": null, "axis_line_alpha": 1.0, "axis_line_cap": "butt", "axis_line_color": "black", "axis_line_dash": [], "axis_line_dash_offset": 0, "axis_line_join": "bevel", "axis_line_width": 1, "background_fill_alpha": 1.0, "background_fill_color": null, "bounds": "auto", "context_menu": null, "coordinates": null, "css_classes": [], "css_variables": { "type": "map" }, "dimension": "auto", "face": "auto", "fixed_location": null, "formatter": { "name": "unset", "type": "symbol" }, "group": null, "id": "p55048", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "guide", "major_label_orientation": "horizontal", "major_label_overrides": { "type": "map" }, "major_label_policy": { "id": "p55049", "name": "AllLabels", "type": "object" }, "major_label_standoff": 5, "major_label_text_align": "center", "major_label_text_alpha": 1.0, "major_label_text_baseline": "alphabetic", "major_label_text_color": "#444444", "major_label_text_font": "helvetica", "major_label_text_font_size": "11px", "major_label_text_font_style": "normal", "major_label_text_line_height": 1.2, "major_label_text_outline_color": null, "major_tick_in": 2, "major_tick_line_alpha": 1.0, "major_tick_line_cap": "butt", "major_tick_line_color": "black", "major_tick_line_dash": [], "major_tick_line_dash_offset": 0, "major_tick_line_join": "bevel", "major_tick_line_width": 1, "major_tick_out": 6, "minor_tick_in": 0, "minor_tick_line_alpha": 1.0, "minor_tick_line_cap": "butt", "minor_tick_line_color": "black", "minor_tick_line_dash": [], "minor_tick_line_dash_offset": 0, "minor_tick_line_join": "bevel", "minor_tick_line_width": 1, "minor_tick_out": 4, "name": null, "propagate_hover": false, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "ticker": { "name": "unset", "type": "symbol" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
- axis_label_orientation = 'parallel'#
- Type:
轴标签文本应该朝向的方向。如果提供了一个数字,文本的角度将从水平方向测量。
- axis_label_text_baseline = 'bottom'#
- Type:
轴标签的文本基线。
- axis_line_dash = []#
- Type:
轴线的虚线样式。
- bounds = 'auto'#
-
渲染轴的边界。如果未设置,轴将在给定维度上跨越整个绘图。
- css_variables = {}#
-
允许定义动态计算的CSS变量。
例如,这可以用于协调canvas渲染器和/或视觉效果与基于HTML的UI元素之间的定位和样式。
这里定义的变量等同于在CSS样式表中的
:host { ... }下设置相同的变量。注意
此属性是实验性的,可能会随时更改。
- dimension = 'auto'#
-
这允许在支持此功能的上下文中覆盖推断的尺寸。当轴用作框架轴时,此属性无效。
注意
此属性是实验性的,可能会随时更改。
- fixed_location = None#
-
设置为指定一个固定的坐标位置来绘制轴。刻度和主要标签的方向由轴所属的侧面板决定。
注意
当坐标轴位于中央绘图区域内的固定位置时,坐标轴标签会被隐藏。
- formatter = Undefined#
- Type:
用于格式化刻度视觉外观的
TickFormatter。
- group = None#
- Type:
注意
此属性是实验性的,可能会随时更改。
- level = 'guide'#
- Type:
指定绘制此渲染器的层级。
- major_label_orientation = 'horizontal'#
- Type:
主要标签文本的方向应该如何确定。如果提供了一个数字,文本的角度将从水平方向测量。
- major_label_overrides = {}#
-
为特定的刻度位置提供明确的刻度标签值,这些值会覆盖正常的格式化。
- major_label_policy = AllLabels(id='p55120', ...)#
- Type:
Instance(LabelingPolicy)
允许过滤掉标签,例如整理标签以避免重叠。
- major_label_text_baseline = 'alphabetic'#
- Type:
主要刻度标签的文本基线。
- major_tick_line_dash = []#
- Type:
主要刻度线的虚线样式。
- minor_tick_line_dash = []#
- Type:
次要刻度线的虚线样式。
- name = None#
-
此模型的任意用户提供的名称。
在查询文档以检索特定Bokeh模型时,此名称可能很有用。
>>> plot.circle([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
注意
对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。
- stylesheets = []#
- Type:
用于底层DOM元素的附加样式表。
请注意,所有Bokeh的组件都使用影子DOM,因此任何包含的样式表都必须反映这一点,例如使用
:hostCSS伪选择器来访问根DOM元素。
- syncable = True#
- Type:
指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为
False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。注意
将此属性设置为
False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。
- tags = []#
- Type:
一个可选的任意用户提供的值列表,用于附加到此模型。
在查询文档以检索特定Bokeh模型时,这些数据可能很有用:
>>> r = plot.circle([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过
CustomJS回调等方式访问。注意
对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。
- ticker = Undefined#
-
用于计算轴组件位置的Ticker。
该属性也可以传递一系列浮点数作为创建和配置
FixedTicker的简写,例如以下代码from bokeh.plotting import figure p = figure() p.xaxis.ticker = [10, 20, 37.4]
等同于:
from bokeh.plotting import figure from bokeh.models import FixedTicker p = figure() p.xaxis.ticker = FixedTicker(ticks=[10, 20, 37.4])
- apply_theme(property_values: dict[str, Any]) None#
应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。
传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和
HasProps实例都不应修改它)。- Parameters:
property_values (dict) – 用于替换默认值的主题值
- Returns:
无
- classmethod clear_extensions() None#
清除当前定义的所有自定义扩展。
序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。
- classmethod descriptors() list[PropertyDescriptor[Any]]#
属性描述符的列表,按定义的顺序排列。
- equals(other: HasProps) bool#
模型的结构相等性。
- Parameters:
其他 (HasProps) – 要比较的其他实例
- Returns:
如果属性在结构上相等,则为True,否则为False
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
使用JavaScript链接两个Bokeh模型属性。
这是一个便捷的方法,简化了添加一个
CustomJS回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。- Parameters:
在版本1.1中添加
- Raises:
示例
这段代码使用了
js_link:select.js_link('value', plot, 'sizing_mode')
等同于以下内容:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
这相当于:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
- js_on_change(event: str, *callbacks: JSChangeCallback) None#
将一个
CustomJS回调附加到任意的BokehJS模型事件。在BokehJS方面,模型属性的更改事件具有
"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到
ColumnDataSource时运行回调,可以在源上使用"stream"事件:source.js_on_change('streaming', callback)
- classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#
在类上找到Bokeh属性的
PropertyDescriptor,给定属性名称。- Parameters:
- Returns:
名为
name的属性的描述符- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
在此对象上添加一个回调,当
attr发生变化时触发。- Parameters:
attr (str) – 此对象上的一个属性名称
*callbacks (callable) – 要注册的回调函数
- Returns:
无
示例
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#
当此模型上发生指定事件时运行回调
并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。
- classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#
收集此类的属性名称。
警告
在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在
list中。- Returns:
属性名称
- classmethod properties_with_refs() dict[str, Property[Any]]#
收集此类上所有具有引用的属性的名称。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
- properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
收集一个将属性名称映射到其值的字典。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。
- query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
使用谓词查询
HasProps实例的属性值。
- select(selector: SelectorType) Iterable[Model]#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
- Returns:
序列[模型]
- select_one(selector: SelectorType) Model | None#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like
- Returns:
模型
- set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#
从JSON设置此对象的属性值。
- Parameters:
name (str) – 要设置的属性名称
value (JSON-value) – 要设置给属性的值
setter (ClientSession 或 ServerSession 或 None, 可选) –
这用于防止对Bokeh应用程序的“回旋镖”更新。
在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。
- Returns:
无
- set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#
使用指定的属性/值更新来更新与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
更新 (dict)
- Returns:
无
- themed_values() dict[str, Any] | None#
获取任何主题提供的覆盖。
结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回
None。- Returns:
字典或无
- to_serializable(serializer: Serializer) ObjectRefRep#
将此对象转换为可序列化的表示形式。
- trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
- class DatetimeAxis(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
基础类:
LinearAxis一个
LinearAxis,它在日期时间尺度上为刻度位置选择适当的数字。默认情况下,使用DatetimeTickFormatter进行配置。JSON Prototype
{ "axis_label": null, "axis_label_align": "center", "axis_label_orientation": "parallel", "axis_label_standoff": 5, "axis_label_text_align": "left", "axis_label_text_alpha": 1.0, "axis_label_text_baseline": "bottom", "axis_label_text_color": "#444444", "axis_label_text_font": "helvetica", "axis_label_text_font_size": "13px", "axis_label_text_font_style": "italic", "axis_label_text_line_height": 1.2, "axis_label_text_outline_color": null, "axis_line_alpha": 1.0, "axis_line_cap": "butt", "axis_line_color": "black", "axis_line_dash": [], "axis_line_dash_offset": 0, "axis_line_join": "bevel", "axis_line_width": 1, "background_fill_alpha": 1.0, "background_fill_color": null, "bounds": "auto", "context_menu": null, "coordinates": null, "css_classes": [], "css_variables": { "type": "map" }, "dimension": "auto", "face": "auto", "fixed_location": null, "formatter": { "id": "p55211", "name": "DatetimeTickFormatter", "type": "object" }, "group": null, "id": "p55197", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "guide", "major_label_orientation": "horizontal", "major_label_overrides": { "type": "map" }, "major_label_policy": { "id": "p55212", "name": "AllLabels", "type": "object" }, "major_label_standoff": 5, "major_label_text_align": "center", "major_label_text_alpha": 1.0, "major_label_text_baseline": "alphabetic", "major_label_text_color": "#444444", "major_label_text_font": "helvetica", "major_label_text_font_size": "11px", "major_label_text_font_style": "normal", "major_label_text_line_height": 1.2, "major_label_text_outline_color": null, "major_tick_in": 2, "major_tick_line_alpha": 1.0, "major_tick_line_cap": "butt", "major_tick_line_color": "black", "major_tick_line_dash": [], "major_tick_line_dash_offset": 0, "major_tick_line_join": "bevel", "major_tick_line_width": 1, "major_tick_out": 6, "minor_tick_in": 0, "minor_tick_line_alpha": 1.0, "minor_tick_line_cap": "butt", "minor_tick_line_color": "black", "minor_tick_line_dash": [], "minor_tick_line_dash_offset": 0, "minor_tick_line_join": "bevel", "minor_tick_line_width": 1, "minor_tick_out": 4, "name": null, "propagate_hover": false, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "ticker": { "attributes": { "tickers": [ { "attributes": { "mantissas": [ 1, 2, 5 ], "max_interval": 500.0, "num_minor_ticks": 0 }, "id": "p55199", "name": "AdaptiveTicker", "type": "object" }, { "attributes": { "base": 60, "mantissas": [ 1, 2, 5, 10, 15, 20, 30 ], "max_interval": 1800000.0, "min_interval": 1000.0, "num_minor_ticks": 0 }, "id": "p55200", "name": "AdaptiveTicker", "type": "object" }, { "attributes": { "base": 24, "mantissas": [ 1, 2, 4, 6, 8, 12 ], "max_interval": 43200000.0, "min_interval": 3600000.0, "num_minor_ticks": 0 }, "id": "p55201", "name": "AdaptiveTicker", "type": "object" }, { "attributes": { "days": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 ] }, "id": "p55202", "name": "DaysTicker", "type": "object" }, { "attributes": { "days": [ 1, 4, 7, 10, 13, 16, 19, 22, 25, 28 ] }, "id": "p55203", "name": "DaysTicker", "type": "object" }, { "attributes": { "days": [ 1, 8, 15, 22 ] }, "id": "p55204", "name": "DaysTicker", "type": "object" }, { "attributes": { "days": [ 1, 15 ] }, "id": "p55205", "name": "DaysTicker", "type": "object" }, { "attributes": { "months": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] }, "id": "p55206", "name": "MonthsTicker", "type": "object" }, { "attributes": { "months": [ 0, 2, 4, 6, 8, 10 ] }, "id": "p55207", "name": "MonthsTicker", "type": "object" }, { "attributes": { "months": [ 0, 4, 8 ] }, "id": "p55208", "name": "MonthsTicker", "type": "object" }, { "attributes": { "months": [ 0, 6 ] }, "id": "p55209", "name": "MonthsTicker", "type": "object" }, { "id": "p55210", "name": "YearsTicker", "type": "object" } ] }, "id": "p55198", "name": "DatetimeTicker", "type": "object" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
- axis_label_orientation = 'parallel'#
- Type:
轴标签文本应该朝向的方向。如果提供了一个数字,文本的角度将从水平方向测量。
- axis_label_text_baseline = 'bottom'#
- Type:
轴标签的文本基线。
- axis_line_dash = []#
- Type:
轴线的虚线样式。
- bounds = 'auto'#
-
渲染轴的边界。如果未设置,轴将在给定维度上跨越整个绘图。
- css_variables = {}#
-
允许定义动态计算的CSS变量。
例如,这可以用于协调canvas渲染器和/或视觉效果与基于HTML的UI元素之间的定位和样式。
这里定义的变量等同于在CSS样式表中的
:host { ... }下设置相同的变量。注意
此属性是实验性的,可能会随时更改。
- dimension = 'auto'#
-
这允许在支持此功能的上下文中覆盖推断的尺寸。当轴用作框架轴时,此属性无效。
注意
此属性是实验性的,可能会随时更改。
- fixed_location = None#
-
设置为指定一个固定的坐标位置来绘制轴。刻度和主要标签的方向由轴所属的侧面板决定。
注意
当坐标轴位于中央绘图区域内的固定位置时,坐标轴标签会被隐藏。
- formatter = DatetimeTickFormatter(id='p55693', ...)#
- Type:
用于格式化刻度视觉外观的
TickFormatter。
- group = None#
- Type:
注意
此属性是实验性的,可能会随时更改。
- level = 'guide'#
- Type:
指定绘制此渲染器的层级。
- major_label_orientation = 'horizontal'#
- Type:
主要标签文本的方向应该如何确定。如果提供了一个数字,文本的角度将从水平方向测量。
- major_label_overrides = {}#
-
为特定的刻度位置提供明确的刻度标签值,这些值会覆盖正常的格式化。
- major_label_policy = AllLabels(id='p55774', ...)#
- Type:
Instance(LabelingPolicy)
允许过滤掉标签,例如整理标签以避免重叠。
- major_label_text_baseline = 'alphabetic'#
- Type:
主要刻度标签的文本基线。
- major_tick_line_dash = []#
- Type:
主要刻度线的虚线样式。
- minor_tick_line_dash = []#
- Type:
次要刻度线的虚线样式。
- name = None#
-
此模型的任意用户提供的名称。
在查询文档以检索特定Bokeh模型时,此名称可能很有用。
>>> plot.circle([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
注意
对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。
- stylesheets = []#
- Type:
用于底层DOM元素的附加样式表。
请注意,所有Bokeh的组件都使用影子DOM,因此任何包含的样式表都必须反映这一点,例如使用
:hostCSS伪选择器来访问根DOM元素。
- syncable = True#
- Type:
指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为
False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。注意
将此属性设置为
False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。
- tags = []#
- Type:
一个可选的任意用户提供的值列表,用于附加到此模型。
在查询文档以检索特定Bokeh模型时,这些数据可能很有用:
>>> r = plot.circle([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过
CustomJS回调等方式访问。注意
对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。
- ticker = DatetimeTicker(id='p56335', ...)#
-
用于计算轴组件位置的Ticker。
该属性也可以传递一系列浮点数作为创建和配置
FixedTicker的简写,例如以下代码from bokeh.plotting import figure p = figure() p.xaxis.ticker = [10, 20, 37.4]
等同于:
from bokeh.plotting import figure from bokeh.models import FixedTicker p = figure() p.xaxis.ticker = FixedTicker(ticks=[10, 20, 37.4])
- apply_theme(property_values: dict[str, Any]) None#
应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。
传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和
HasProps实例都不应修改它)。- Parameters:
property_values (dict) – 用于替换默认值的主题值
- Returns:
无
- classmethod clear_extensions() None#
清除当前定义的所有自定义扩展。
序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。
- classmethod descriptors() list[PropertyDescriptor[Any]]#
属性描述符的列表,按定义的顺序排列。
- equals(other: HasProps) bool#
模型的结构相等性。
- Parameters:
其他 (HasProps) – 要比较的其他实例
- Returns:
如果属性在结构上相等,则为True,否则为False
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
使用JavaScript链接两个Bokeh模型属性。
这是一个便捷的方法,简化了添加一个
CustomJS回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。- Parameters:
在版本1.1中添加
- Raises:
示例
这段代码使用了
js_link:select.js_link('value', plot, 'sizing_mode')
等同于以下内容:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
这相当于:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
- js_on_change(event: str, *callbacks: JSChangeCallback) None#
将一个
CustomJS回调附加到任意的BokehJS模型事件。在BokehJS方面,模型属性的更改事件具有
"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到
ColumnDataSource时运行回调,可以在源上使用"stream"事件:source.js_on_change('streaming', callback)
- classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#
在类上找到Bokeh属性的
PropertyDescriptor,给定属性名称。- Parameters:
- Returns:
名为
name的属性的描述符- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
在此对象上添加一个回调,当
attr发生变化时触发。- Parameters:
attr (str) – 此对象上的一个属性名称
*callbacks (callable) – 要注册的回调函数
- Returns:
无
示例
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#
当此模型上发生指定事件时运行回调
并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。
- classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#
收集此类的属性名称。
警告
在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在
list中。- Returns:
属性名称
- classmethod properties_with_refs() dict[str, Property[Any]]#
收集此类上所有具有引用的属性的名称。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
- properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
收集一个将属性名称映射到其值的字典。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。
- query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
使用谓词查询
HasProps实例的属性值。
- select(selector: SelectorType) Iterable[Model]#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
- Returns:
序列[模型]
- select_one(selector: SelectorType) Model | None#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like
- Returns:
模型
- set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#
从JSON设置此对象的属性值。
- Parameters:
name (str) – 要设置的属性名称
value (JSON-value) – 要设置给属性的值
setter (ClientSession 或 ServerSession 或 None, 可选) –
这用于防止对Bokeh应用程序的“回旋镖”更新。
在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。
- Returns:
无
- set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#
使用指定的属性/值更新来更新与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
更新 (dict)
- Returns:
无
- themed_values() dict[str, Any] | None#
获取任何主题提供的覆盖。
结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回
None。- Returns:
字典或无
- to_serializable(serializer: Serializer) ObjectRefRep#
将此对象转换为可序列化的表示形式。
- trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
- class LinearAxis(*args: Any, id: ID | None = None, **kwargs: Any)[源代码]#
基础类:
ContinuousAxis一个在线性比例上为刻度位置选择合适数字的轴。默认配置为
BasicTickFormatter。JSON Prototype
{ "axis_label": null, "axis_label_align": "center", "axis_label_orientation": "parallel", "axis_label_standoff": 5, "axis_label_text_align": "left", "axis_label_text_alpha": 1.0, "axis_label_text_baseline": "bottom", "axis_label_text_color": "#444444", "axis_label_text_font": "helvetica", "axis_label_text_font_size": "13px", "axis_label_text_font_style": "italic", "axis_label_text_line_height": 1.2, "axis_label_text_outline_color": null, "axis_line_alpha": 1.0, "axis_line_cap": "butt", "axis_line_color": "black", "axis_line_dash": [], "axis_line_dash_offset": 0, "axis_line_join": "bevel", "axis_line_width": 1, "background_fill_alpha": 1.0, "background_fill_color": null, "bounds": "auto", "context_menu": null, "coordinates": null, "css_classes": [], "css_variables": { "type": "map" }, "dimension": "auto", "face": "auto", "fixed_location": null, "formatter": { "id": "p56398", "name": "BasicTickFormatter", "type": "object" }, "group": null, "id": "p56396", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "guide", "major_label_orientation": "horizontal", "major_label_overrides": { "type": "map" }, "major_label_policy": { "id": "p56399", "name": "AllLabels", "type": "object" }, "major_label_standoff": 5, "major_label_text_align": "center", "major_label_text_alpha": 1.0, "major_label_text_baseline": "alphabetic", "major_label_text_color": "#444444", "major_label_text_font": "helvetica", "major_label_text_font_size": "11px", "major_label_text_font_style": "normal", "major_label_text_line_height": 1.2, "major_label_text_outline_color": null, "major_tick_in": 2, "major_tick_line_alpha": 1.0, "major_tick_line_cap": "butt", "major_tick_line_color": "black", "major_tick_line_dash": [], "major_tick_line_dash_offset": 0, "major_tick_line_join": "bevel", "major_tick_line_width": 1, "major_tick_out": 6, "minor_tick_in": 0, "minor_tick_line_alpha": 1.0, "minor_tick_line_cap": "butt", "minor_tick_line_color": "black", "minor_tick_line_dash": [], "minor_tick_line_dash_offset": 0, "minor_tick_line_join": "bevel", "minor_tick_line_width": 1, "minor_tick_out": 4, "name": null, "propagate_hover": false, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "ticker": { "attributes": { "mantissas": [ 1, 2, 5 ] }, "id": "p56397", "name": "BasicTicker", "type": "object" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
- axis_label_orientation = 'parallel'#
- Type:
轴标签文本应该朝向的方向。如果提供了一个数字,文本的角度将从水平方向测量。
- axis_label_text_baseline = 'bottom'#
- Type:
轴标签的文本基线。
- axis_line_dash = []#
- Type:
轴线的虚线样式。
- bounds = 'auto'#
-
渲染轴的边界。如果未设置,轴将在给定维度上跨越整个绘图。
- css_variables = {}#
-
允许定义动态计算的CSS变量。
例如,这可以用于协调canvas渲染器和/或视觉效果与基于HTML的UI元素之间的定位和样式。
这里定义的变量等同于在CSS样式表中的
:host { ... }下设置相同的变量。注意
此属性是实验性的,可能会随时更改。
- dimension = 'auto'#
-
这允许在支持此功能的上下文中覆盖推断的尺寸。当轴用作框架轴时,此属性无效。
注意
此属性是实验性的,可能会随时更改。
- fixed_location = None#
-
设置为指定一个固定的坐标位置来绘制轴。刻度和主要标签的方向由轴所属的侧面板决定。
注意
当坐标轴位于中央绘图区域内的固定位置时,坐标轴标签会被隐藏。
- formatter = BasicTickFormatter(id='p56520', ...)#
- Type:
用于格式化刻度视觉外观的
TickFormatter。
- group = None#
- Type:
注意
此属性是实验性的,可能会随时更改。
- level = 'guide'#
- Type:
指定绘制此渲染器的层级。
- major_label_orientation = 'horizontal'#
- Type:
主要标签文本的方向应该如何确定。如果提供了一个数字,文本的角度将从水平方向测量。
- major_label_overrides = {}#
-
为特定的刻度位置提供明确的刻度标签值,这些值会覆盖正常的格式化。
- major_label_policy = AllLabels(id='p56541', ...)#
- Type:
Instance(LabelingPolicy)
允许过滤掉标签,例如整理标签以避免重叠。
- major_label_text_baseline = 'alphabetic'#
- Type:
主要刻度标签的文本基线。
- major_tick_line_dash = []#
- Type:
主要刻度线的虚线样式。
- minor_tick_line_dash = []#
- Type:
次要刻度线的虚线样式。
- name = None#
-
此模型的任意用户提供的名称。
在查询文档以检索特定Bokeh模型时,此名称可能很有用。
>>> plot.circle([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
注意
对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。
- stylesheets = []#
- Type:
用于底层DOM元素的附加样式表。
请注意,所有Bokeh的组件都使用影子DOM,因此任何包含的样式表都必须反映这一点,例如使用
:hostCSS伪选择器来访问根DOM元素。
- syncable = True#
- Type:
指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为
False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。注意
将此属性设置为
False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。
- tags = []#
- Type:
一个可选的任意用户提供的值列表,用于附加到此模型。
在查询文档以检索特定Bokeh模型时,这些数据可能很有用:
>>> r = plot.circle([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过
CustomJS回调等方式访问。注意
对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。
- ticker = BasicTicker(id='p56682', ...)#
-
用于计算轴组件位置的Ticker。
该属性也可以传递一系列浮点数作为创建和配置
FixedTicker的简写,例如以下代码from bokeh.plotting import figure p = figure() p.xaxis.ticker = [10, 20, 37.4]
等同于:
from bokeh.plotting import figure from bokeh.models import FixedTicker p = figure() p.xaxis.ticker = FixedTicker(ticks=[10, 20, 37.4])
- apply_theme(property_values: dict[str, Any]) None#
应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。
传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和
HasProps实例都不应修改它)。- Parameters:
property_values (dict) – 用于替换默认值的主题值
- Returns:
无
- classmethod clear_extensions() None#
清除当前定义的所有自定义扩展。
序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。
- classmethod descriptors() list[PropertyDescriptor[Any]]#
属性描述符的列表,按定义的顺序排列。
- equals(other: HasProps) bool#
模型的结构相等性。
- Parameters:
其他 (HasProps) – 要比较的其他实例
- Returns:
如果属性在结构上相等,则为True,否则为False
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
使用JavaScript链接两个Bokeh模型属性。
这是一个便捷的方法,简化了添加一个
CustomJS回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。- Parameters:
在版本1.1中添加
- Raises:
示例
这段代码使用了
js_link:select.js_link('value', plot, 'sizing_mode')
等同于以下内容:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
这相当于:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
- js_on_change(event: str, *callbacks: JSChangeCallback) None#
将一个
CustomJS回调附加到任意的BokehJS模型事件。在BokehJS方面,模型属性的更改事件具有
"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到
ColumnDataSource时运行回调,可以在源上使用"stream"事件:source.js_on_change('streaming', callback)
- classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#
在类上找到Bokeh属性的
PropertyDescriptor,给定属性名称。- Parameters:
- Returns:
名为
name的属性的描述符- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
在此对象上添加一个回调,当
attr发生变化时触发。- Parameters:
attr (str) – 此对象上的一个属性名称
*callbacks (callable) – 要注册的回调函数
- Returns:
无
示例
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#
当此模型上发生指定事件时运行回调
并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。
- classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#
收集此类的属性名称。
警告
在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在
list中。- Returns:
属性名称
- classmethod properties_with_refs() dict[str, Property[Any]]#
收集此类上所有具有引用的属性的名称。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
- properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
收集一个将属性名称映射到其值的字典。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。
- query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
使用谓词查询
HasProps实例的属性值。
- select(selector: SelectorType) Iterable[Model]#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
- Returns:
序列[模型]
- select_one(selector: SelectorType) Model | None#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like
- Returns:
模型
- set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#
从JSON设置此对象的属性值。
- Parameters:
name (str) – 要设置的属性名称
value (JSON-value) – 要设置给属性的值
setter (ClientSession 或 ServerSession 或 None, 可选) –
这用于防止对Bokeh应用程序的“回旋镖”更新。
在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。
- Returns:
无
- set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#
使用指定的属性/值更新来更新与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
更新 (dict)
- Returns:
无
- themed_values() dict[str, Any] | None#
获取任何主题提供的覆盖。
结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回
None。- Returns:
字典或无
- to_serializable(serializer: Serializer) ObjectRefRep#
将此对象转换为可序列化的表示形式。
- trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
- class LogAxis(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
基础类:
ContinuousAxis一个在对数刻度上为刻度位置选择合适数字的轴。默认配置为
LogTickFormatter。JSON Prototype
{ "axis_label": null, "axis_label_align": "center", "axis_label_orientation": "parallel", "axis_label_standoff": 5, "axis_label_text_align": "left", "axis_label_text_alpha": 1.0, "axis_label_text_baseline": "bottom", "axis_label_text_color": "#444444", "axis_label_text_font": "helvetica", "axis_label_text_font_size": "13px", "axis_label_text_font_style": "italic", "axis_label_text_line_height": 1.2, "axis_label_text_outline_color": null, "axis_line_alpha": 1.0, "axis_line_cap": "butt", "axis_line_color": "black", "axis_line_dash": [], "axis_line_dash_offset": 0, "axis_line_join": "bevel", "axis_line_width": 1, "background_fill_alpha": 1.0, "background_fill_color": null, "bounds": "auto", "context_menu": null, "coordinates": null, "css_classes": [], "css_variables": { "type": "map" }, "dimension": "auto", "face": "auto", "fixed_location": null, "formatter": { "id": "p56697", "name": "LogTickFormatter", "type": "object" }, "group": null, "id": "p56695", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "guide", "major_label_orientation": "horizontal", "major_label_overrides": { "type": "map" }, "major_label_policy": { "id": "p56698", "name": "AllLabels", "type": "object" }, "major_label_standoff": 5, "major_label_text_align": "center", "major_label_text_alpha": 1.0, "major_label_text_baseline": "alphabetic", "major_label_text_color": "#444444", "major_label_text_font": "helvetica", "major_label_text_font_size": "11px", "major_label_text_font_style": "normal", "major_label_text_line_height": 1.2, "major_label_text_outline_color": null, "major_tick_in": 2, "major_tick_line_alpha": 1.0, "major_tick_line_cap": "butt", "major_tick_line_color": "black", "major_tick_line_dash": [], "major_tick_line_dash_offset": 0, "major_tick_line_join": "bevel", "major_tick_line_width": 1, "major_tick_out": 6, "minor_tick_in": 0, "minor_tick_line_alpha": 1.0, "minor_tick_line_cap": "butt", "minor_tick_line_color": "black", "minor_tick_line_dash": [], "minor_tick_line_dash_offset": 0, "minor_tick_line_join": "bevel", "minor_tick_line_width": 1, "minor_tick_out": 4, "name": null, "propagate_hover": false, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "ticker": { "attributes": { "mantissas": [ 1, 5 ] }, "id": "p56696", "name": "LogTicker", "type": "object" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
- axis_label_orientation = 'parallel'#
- Type:
轴标签文本应该朝向的方向。如果提供了一个数字,文本的角度将从水平方向测量。
- axis_label_text_baseline = 'bottom'#
- Type:
轴标签的文本基线。
- axis_line_dash = []#
- Type:
轴线的虚线样式。
- bounds = 'auto'#
-
渲染轴的边界。如果未设置,轴将在给定维度上跨越整个绘图。
- css_variables = {}#
-
允许定义动态计算的CSS变量。
例如,这可以用于协调canvas渲染器和/或视觉效果与基于HTML的UI元素之间的定位和样式。
这里定义的变量等同于在CSS样式表中的
:host { ... }下设置相同的变量。注意
此属性是实验性的,可能会随时更改。
- dimension = 'auto'#
-
这允许在支持此功能的上下文中覆盖推断的尺寸。当轴用作框架轴时,此属性无效。
注意
此属性是实验性的,可能会随时更改。
- fixed_location = None#
-
设置为指定一个固定的坐标位置来绘制轴。刻度和主要标签的方向由轴所属的侧面板决定。
注意
当坐标轴位于中央绘图区域内的固定位置时,坐标轴标签会被隐藏。
- formatter = LogTickFormatter(id='p56819', ...)#
- Type:
用于格式化刻度视觉外观的
TickFormatter。
- group = None#
- Type:
注意
此属性是实验性的,可能会随时更改。
- level = 'guide'#
- Type:
指定绘制此渲染器的层级。
- major_label_orientation = 'horizontal'#
- Type:
主要标签文本的方向应该如何确定。如果提供了一个数字,文本的角度将从水平方向测量。
- major_label_overrides = {}#
-
为特定的刻度位置提供明确的刻度标签值,这些值会覆盖正常的格式化。
- major_label_policy = AllLabels(id='p56840', ...)#
- Type:
Instance(LabelingPolicy)
允许过滤掉标签,例如整理标签以避免重叠。
- major_label_text_baseline = 'alphabetic'#
- Type:
主要刻度标签的文本基线。
- major_tick_line_dash = []#
- Type:
主要刻度线的虚线样式。
- minor_tick_line_dash = []#
- Type:
次要刻度线的虚线样式。
- name = None#
-
此模型的任意用户提供的名称。
在查询文档以检索特定Bokeh模型时,此名称可能很有用。
>>> plot.circle([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
注意
对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。
- stylesheets = []#
- Type:
用于底层DOM元素的附加样式表。
请注意,所有Bokeh的组件都使用影子DOM,因此任何包含的样式表都必须反映这一点,例如使用
:hostCSS伪选择器来访问根DOM元素。
- syncable = True#
- Type:
指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为
False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。注意
将此属性设置为
False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。
- tags = []#
- Type:
一个可选的任意用户提供的值列表,用于附加到此模型。
在查询文档以检索特定Bokeh模型时,这些数据可能很有用:
>>> r = plot.circle([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过
CustomJS回调等方式访问。注意
对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。
- ticker = LogTicker(id='p56981', ...)#
-
用于计算轴组件位置的Ticker。
该属性也可以传递一系列浮点数作为创建和配置
FixedTicker的简写,例如以下代码from bokeh.plotting import figure p = figure() p.xaxis.ticker = [10, 20, 37.4]
等同于:
from bokeh.plotting import figure from bokeh.models import FixedTicker p = figure() p.xaxis.ticker = FixedTicker(ticks=[10, 20, 37.4])
- apply_theme(property_values: dict[str, Any]) None#
应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。
传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和
HasProps实例都不应修改它)。- Parameters:
property_values (dict) – 用于替换默认值的主题值
- Returns:
无
- classmethod clear_extensions() None#
清除当前定义的所有自定义扩展。
序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。
- classmethod descriptors() list[PropertyDescriptor[Any]]#
属性描述符的列表,按定义的顺序排列。
- equals(other: HasProps) bool#
模型的结构相等性。
- Parameters:
其他 (HasProps) – 要比较的其他实例
- Returns:
如果属性在结构上相等,则为True,否则为False
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
使用JavaScript链接两个Bokeh模型属性。
这是一个便捷的方法,简化了添加一个
CustomJS回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。- Parameters:
在版本1.1中添加
- Raises:
示例
这段代码使用了
js_link:select.js_link('value', plot, 'sizing_mode')
等同于以下内容:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
这相当于:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
- js_on_change(event: str, *callbacks: JSChangeCallback) None#
将一个
CustomJS回调附加到任意的BokehJS模型事件。在BokehJS方面,模型属性的更改事件具有
"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到
ColumnDataSource时运行回调,可以在源上使用"stream"事件:source.js_on_change('streaming', callback)
- classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#
在类上找到Bokeh属性的
PropertyDescriptor,给定属性名称。- Parameters:
- Returns:
名为
name的属性的描述符- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
在此对象上添加一个回调,当
attr发生变化时触发。- Parameters:
attr (str) – 此对象上的一个属性名称
*callbacks (callable) – 要注册的回调函数
- Returns:
无
示例
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#
当此模型上发生指定事件时运行回调
并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。
- classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#
收集此类的属性名称。
警告
在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在
list中。- Returns:
属性名称
- classmethod properties_with_refs() dict[str, Property[Any]]#
收集此类上所有具有引用的属性的名称。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
- properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
收集一个将属性名称映射到其值的字典。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。
- query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
使用谓词查询
HasProps实例的属性值。
- select(selector: SelectorType) Iterable[Model]#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
- Returns:
序列[模型]
- select_one(selector: SelectorType) Model | None#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like
- Returns:
模型
- set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#
从JSON设置此对象的属性值。
- Parameters:
name (str) – 要设置的属性名称
value (JSON-value) – 要设置给属性的值
setter (ClientSession 或 ServerSession 或 None, 可选) –
这用于防止对Bokeh应用程序的“回旋镖”更新。
在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。
- Returns:
无
- set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#
使用指定的属性/值更新来更新与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
更新 (dict)
- Returns:
无
- themed_values() dict[str, Any] | None#
获取任何主题提供的覆盖。
结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回
None。- Returns:
字典或无
- to_serializable(serializer: Serializer) ObjectRefRep#
将此对象转换为可序列化的表示形式。
- trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
- class MercatorAxis(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
基础类:
LinearAxis一个为墨卡托比例尺上的刻度位置选择合适数字的轴。默认配置为
MercatorTickFormatter。- Parameters:
维度 ('lat' 或 'lon', 可选) – 此轴将显示纬度还是经度值。 (默认: ‘lat’)
JSON Prototype
{ "axis_label": null, "axis_label_align": "center", "axis_label_orientation": "parallel", "axis_label_standoff": 5, "axis_label_text_align": "left", "axis_label_text_alpha": 1.0, "axis_label_text_baseline": "bottom", "axis_label_text_color": "#444444", "axis_label_text_font": "helvetica", "axis_label_text_font_size": "13px", "axis_label_text_font_style": "italic", "axis_label_text_line_height": 1.2, "axis_label_text_outline_color": null, "axis_line_alpha": 1.0, "axis_line_cap": "butt", "axis_line_color": "black", "axis_line_dash": [], "axis_line_dash_offset": 0, "axis_line_join": "bevel", "axis_line_width": 1, "background_fill_alpha": 1.0, "background_fill_color": null, "bounds": "auto", "context_menu": null, "coordinates": null, "css_classes": [], "css_variables": { "type": "map" }, "dimension": "auto", "face": "auto", "fixed_location": null, "formatter": { "attributes": { "dimension": "lat" }, "id": "p56996", "name": "MercatorTickFormatter", "type": "object" }, "group": null, "id": "p56994", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "guide", "major_label_orientation": "horizontal", "major_label_overrides": { "type": "map" }, "major_label_policy": { "id": "p56997", "name": "AllLabels", "type": "object" }, "major_label_standoff": 5, "major_label_text_align": "center", "major_label_text_alpha": 1.0, "major_label_text_baseline": "alphabetic", "major_label_text_color": "#444444", "major_label_text_font": "helvetica", "major_label_text_font_size": "11px", "major_label_text_font_style": "normal", "major_label_text_line_height": 1.2, "major_label_text_outline_color": null, "major_tick_in": 2, "major_tick_line_alpha": 1.0, "major_tick_line_cap": "butt", "major_tick_line_color": "black", "major_tick_line_dash": [], "major_tick_line_dash_offset": 0, "major_tick_line_join": "bevel", "major_tick_line_width": 1, "major_tick_out": 6, "minor_tick_in": 0, "minor_tick_line_alpha": 1.0, "minor_tick_line_cap": "butt", "minor_tick_line_color": "black", "minor_tick_line_dash": [], "minor_tick_line_dash_offset": 0, "minor_tick_line_join": "bevel", "minor_tick_line_width": 1, "minor_tick_out": 4, "name": null, "propagate_hover": false, "styles": { "type": "map" }, "stylesheets": [], "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "ticker": { "attributes": { "dimension": "lat", "mantissas": [ 1, 2, 5 ] }, "id": "p56995", "name": "MercatorTicker", "type": "object" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
- axis_label_orientation = 'parallel'#
- Type:
轴标签文本应该朝向的方向。如果提供了一个数字,文本的角度将从水平方向测量。
- axis_label_text_baseline = 'bottom'#
- Type:
轴标签的文本基线。
- axis_line_dash = []#
- Type:
轴线的虚线样式。
- bounds = 'auto'#
-
渲染轴的边界。如果未设置,轴将在给定维度上跨越整个绘图。
- css_variables = {}#
-
允许定义动态计算的CSS变量。
例如,这可以用于协调canvas渲染器和/或视觉效果与基于HTML的UI元素之间的定位和样式。
这里定义的变量等同于在CSS样式表中的
:host { ... }下设置相同的变量。注意
此属性是实验性的,可能会随时更改。
- dimension = 'auto'#
-
这允许在支持此功能的上下文中覆盖推断的尺寸。当轴用作框架轴时,此属性无效。
注意
此属性是实验性的,可能会随时更改。
- fixed_location = None#
-
设置为指定一个固定的坐标位置来绘制轴。刻度和主要标签的方向由轴所属的侧面板决定。
注意
当坐标轴位于中央绘图区域内的固定位置时,坐标轴标签会被隐藏。
- formatter = MercatorTickFormatter(id='p57118', ...)#
- Type:
用于格式化刻度视觉外观的
TickFormatter。
- group = None#
- Type:
注意
此属性是实验性的,可能会随时更改。
- level = 'guide'#
- Type:
指定绘制此渲染器的层级。
- major_label_orientation = 'horizontal'#
- Type:
主要标签文本的方向应该如何确定。如果提供了一个数字,文本的角度将从水平方向测量。
- major_label_overrides = {}#
-
为特定的刻度位置提供明确的刻度标签值,这些值会覆盖正常的格式化。
- major_label_policy = AllLabels(id='p57139', ...)#
- Type:
Instance(LabelingPolicy)
允许过滤掉标签,例如整理标签以避免重叠。
- major_label_text_baseline = 'alphabetic'#
- Type:
主要刻度标签的文本基线。
- major_tick_line_dash = []#
- Type:
主要刻度线的虚线样式。
- minor_tick_line_dash = []#
- Type:
次要刻度线的虚线样式。
- name = None#
-
此模型的任意用户提供的名称。
在查询文档以检索特定Bokeh模型时,此名称可能很有用。
>>> plot.circle([1,2,3], [4,5,6], name="temp") >>> plot.select(name="temp") [GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]
注意
对于提供的任何名称,没有强制执行唯一性保证或其他条件,Bokeh也不会直接使用这些名称。
- stylesheets = []#
- Type:
用于底层DOM元素的附加样式表。
请注意,所有Bokeh的组件都使用影子DOM,因此任何包含的样式表都必须反映这一点,例如使用
:hostCSS伪选择器来访问根DOM元素。
- syncable = True#
- Type:
指示当在网页浏览器中更新时,此模型是否应同步回Bokeh服务器。设置为
False可能有助于在处理频繁更新的对象时减少网络流量,这些对象的更新值我们不需要。注意
将此属性设置为
False将阻止此对象上的任何on_change()回调触发。然而,任何JS端的回调仍然会工作。
- tags = []#
- Type:
一个可选的任意用户提供的值列表,用于附加到此模型。
在查询文档以检索特定Bokeh模型时,这些数据可能很有用:
>>> r = plot.circle([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
或者只是将任何必要的元数据附加到模型的一种便捷方式,这些元数据可以通过
CustomJS回调等方式访问。注意
对于提供的任何标签,没有强制执行唯一性保证或其他条件,Bokeh也不会出于任何原因直接使用这些标签。
- ticker = MercatorTicker(id='p57280', ...)#
-
用于计算轴组件位置的Ticker。
该属性也可以传递一系列浮点数作为创建和配置
FixedTicker的简写,例如以下代码from bokeh.plotting import figure p = figure() p.xaxis.ticker = [10, 20, 37.4]
等同于:
from bokeh.plotting import figure from bokeh.models import FixedTicker p = figure() p.xaxis.ticker = FixedTicker(ticks=[10, 20, 37.4])
- apply_theme(property_values: dict[str, Any]) None#
应用一组主题值,这些值将用于替代默认值,但不会覆盖应用程序设置的值。
传入的字典可能会保持原样并与其他实例共享以节省内存(因此调用者和
HasProps实例都不应修改它)。- Parameters:
property_values (dict) – 用于替换默认值的主题值
- Returns:
无
- classmethod clear_extensions() None#
清除当前定义的所有自定义扩展。
序列化调用将导致任何当前定义的自定义扩展被包含在生成的文档中,无论是否被使用。此方法可用于清除所有现有的自定义扩展定义。
- classmethod descriptors() list[PropertyDescriptor[Any]]#
属性描述符的列表,按定义的顺序排列。
- equals(other: HasProps) bool#
模型的结构相等性。
- Parameters:
其他 (HasProps) – 要比较的其他实例
- Returns:
如果属性在结构上相等,则为True,否则为False
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
使用JavaScript链接两个Bokeh模型属性。
这是一个便捷的方法,简化了添加一个
CustomJS回调的过程,以便在另一个属性值发生变化时更新一个 Bokeh 模型属性。- Parameters:
在版本1.1中添加
- Raises:
示例
这段代码使用了
js_link:select.js_link('value', plot, 'sizing_mode')
等同于以下内容:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
此外,使用attr_selector将范围滑块的左侧附加到绘图的x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
这相当于:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
- js_on_change(event: str, *callbacks: JSChangeCallback) None#
将一个
CustomJS回调附加到任意的BokehJS模型事件。在BokehJS方面,模型属性的更改事件具有
"change:property_name"的形式。为了方便起见,如果传递给此方法的事件名称也是模型上属性的名称,那么它将自动加上"change:"前缀:# these two are equivalent source.js_on_change('data', callback) source.js_on_change('change:data', callback)
然而,除了属性更改事件之外,还有其他类型的事件可能对响应有用。例如,每当数据流式传输到
ColumnDataSource时运行回调,可以在源上使用"stream"事件:source.js_on_change('streaming', callback)
- classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#
在类上找到Bokeh属性的
PropertyDescriptor,给定属性名称。- Parameters:
- Returns:
名为
name的属性的描述符- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
在此对象上添加一个回调,当
attr发生变化时触发。- Parameters:
attr (str) – 此对象上的一个属性名称
*callbacks (callable) – 要注册的回调函数
- Returns:
无
示例
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#
当此模型上发生指定事件时运行回调
并非所有模型都支持所有事件。 有关哪些模型能够触发特定事件的更多信息,请参见bokeh.events中的具体事件。
- classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#
收集此类的属性名称。
警告
在Bokeh的未来版本中,此方法将返回一个将属性名称映射到属性对象的字典。为了使当前使用此方法的方式具有未来兼容性,请将返回值包装在
list中。- Returns:
属性名称
- classmethod properties_with_refs() dict[str, Property[Any]]#
收集此类上所有具有引用的属性的名称。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
- properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
收集一个将属性名称映射到其值的字典。
此方法始终遍历类层次结构,并包括在任何父类上定义的属性。
不可序列化的属性将被跳过,属性值以“序列化”格式呈现,这可能与您通常从属性中读取的值略有不同;此方法的目的是返回无损重构对象实例所需的信息。
- query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#
使用谓词查询
HasProps实例的属性值。
- select(selector: SelectorType) Iterable[Model]#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
- Returns:
序列[模型]
- select_one(selector: SelectorType) Model | None#
查询此对象及其所有引用,以查找与给定选择器匹配的对象。如果找到多个对象,则引发错误。返回单个匹配对象,如果未找到任何内容,则返回None :param selector: :type selector: JSON-like
- Returns:
模型
- set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#
从JSON设置此对象的属性值。
- Parameters:
name (str) – 要设置的属性名称
value (JSON-value) – 要设置给属性的值
setter (ClientSession 或 ServerSession 或 None, 可选) –
这用于防止对Bokeh应用程序的“回旋镖”更新。
在Bokeh服务器应用程序的上下文中,对属性的传入更新将使用正在执行更新的会话进行注释。该值通过更新触发的任何后续更改通知传播。会话可以将事件设置器与自身进行比较,并抑制源自自身的任何更新。
- Returns:
无
- set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#
使用指定的属性/值更新来更新与给定选择器匹配的对象。
- Parameters:
selector (类似JSON的)
更新 (dict)
- Returns:
无
- themed_values() dict[str, Any] | None#
获取任何主题提供的覆盖。
结果以属性名称到值的字典形式返回,如果此实例没有主题覆盖任何值,则返回
None。- Returns:
字典或无
- to_serializable(serializer: Serializer) ObjectRefRep#
将此对象转换为可序列化的表示形式。
- trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#