Python中的 bokeh.plotting.figure.step()函数
Bokeh是Python中的数据可视化库,提供高性能的交互式图表和绘图,输出可以在笔记本、html 和服务器等各种媒体中获得。 Figure 类创建一个用于绘图的新 Figure。它是 Plot 的子类,使用默认轴、网格、工具等简化绘图创建。
bokeh.plotting.figure.step()函数
bokeh 库的绘图模块中的step()函数用于配置和添加 Step 字形到这个图中。
Syntax: step(x, y, *, line_alpha=1.0, line_cap=’butt’, line_color=’black’, line_dash=[], line_dash_offset=0, line_join=’bevel’, line_width=1, mode=’before’, name=None, tags=[], **kwargs)
Parameters: This method accept the following parameters that are described below:
- x: This parameter is the x-coordinates for the steps.
- y: This parameter is the y-coordinates for the steps.
- line_alpha: This parameter is the line alpha values for the steps with default value of 1.0 .
- line_cap: This parameter is the line cap values for the steps with default value of butt.
- line_color: This parameter is the line color values for the steps with default value of black.
- line_dash: This parameter is the line dash values for the steps with default value of [].
- line_dash_offset: This parameter is the line dash offset values for the steps with default value of 0.
- line_join: This parameter is the line join values for the steps with default value of bevel.
- line_width: This parameter is the line width values for the steps with default value of 1.
- mode: This parameter can be one of three values : [“before”, “after”, “center”].
- name: This parameter is the user-supplied name for this model.
- tags: This parameter is the user-supplied values for this model.
Other Parameters: These parameters are **kwargs that are described below:
- alpha: This parameter is used to set all alpha keyword arguments at once.
- color: This parameter is used to to set all color keyword arguments at once.
- legend_field: This parameter is the name of a column in the data source that should be used or the grouping.
- legend_group: This parameter is the name of a column in the data source that should be used or the grouping.
- legend_label: This parameter is the legend entry is labeled with exactly the text supplied here.
- muted: This parameter contains the bool value.
- name: This parameter is the optional user-supplied name to attach to the renderer.
- source: This parameter is the user-supplied data source.
- view: This parameter is the view for filtering the data source.
- visible: This parameter contains the bool value.
- x_range_name: This parameter is the name of an extra range to use for mapping x-coordinates.
- y_range_name: This parameter is the name of an extra range to use for mapping y-coordinates.
- level: This parameter specify the render level order for this glyph.
Return: This method return the GlyphRenderer value.
以下示例说明了 bokeh.plotting 中的 bokeh.plotting.figure.step()函数:
示例 1:
# Implementation of bokeh function
import numpy as np
from bokeh.plotting import figure, output_file, show
x = np.arange(16)
y = np.sin(x / 3)
plot = figure(plot_width = 300, plot_height = 300)
plot.step(x = x, y = y + 2,
color ='green')
plot.line(x, y + 2, color ='black',
line_alpha = 0.3,
line_dash = "dashed")
show(plot)
输出:
示例 2:
# Implementation of bokeh function
import numpy as np
from bokeh.plotting import figure, output_file, show
x = np.arange(16)
y = np.sin(x / 3)
plot = figure(plot_width=300,
plot_height=300)
plot.step(x=x, y=y+2, color ='blue',
legend_label = 'pre')
plot.line(x, y+2,color ='black',
line_alpha = 0.3 ,
line_dash = "dashed")
plot.step(x=x, y=y+1, color ='orange',
legend_label = 'mid')
plot.line(x, y+1, color ='black',
line_alpha = 0.3 ,
line_dash = "dashed")
plot.step(x=x, y=y, color ='green',
legend_label = 'post')
plot.line(x, y, color ='black',
line_alpha = 0.3 ,
line_dash = "dashed")
show(plot)
输出: