本文整理汇总了Python中bokeh.models.DataRange1d方法的典型用法代码示例。如果您正苦于以下问题:Python models.DataRange1d方法的具体用法?Python models.DataRange1d怎么用?Python models.DataRange1d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.models
的用法示例。
在下文中一共展示了models.DataRange1d方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_plot
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DataRange1d [as 别名]
def make_plot(source, title):
plot = figure(x_axis_type="datetime", plot_width=800, tools="", toolbar_location=None)
plot.title.text = title
plot.quad(top='record_max_temp', bottom='record_min_temp', left='left', right='right',
color=Blues4[2], source=source, legend="Record")
plot.quad(top='average_max_temp', bottom='average_min_temp', left='left', right='right',
color=Blues4[1], source=source, legend="Average")
plot.quad(top='actual_max_temp', bottom='actual_min_temp', left='left', right='right',
color=Blues4[0], alpha=0.5, line_color="black", source=source, legend="Actual")
# fixed attributes
plot.xaxis.axis_label = None
plot.yaxis.axis_label = "Temperature (F)"
plot.axis.axis_label_text_font_style = "bold"
plot.x_range = DataRange1d(range_padding=0.0)
plot.grid.grid_line_alpha = 0.3
return plot
示例2: make_plot
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DataRange1d [as 别名]
def make_plot(self, dataframe):
self.source = ColumnDataSource(data=dataframe)
self.plot = figure(
x_axis_type="datetime", plot_width=600, plot_height=300,
tools='', toolbar_location=None)
self.plot.quad(
top='max_temp', bottom='min_temp', left='left', right='right',
color=Blues4[2], source=self.source, legend='Magnitude')
line = self.plot.line(
x='date', y='avg_temp', line_width=3, color=Blues4[1],
source=self.source, legend='Average')
hover_tool = HoverTool(tooltips=[
('Value', '$y'),
('Date', '@date_readable'),
], renderers=[line])
self.plot.tools.append(hover_tool)
self.plot.xaxis.axis_label = None
self.plot.yaxis.axis_label = None
self.plot.axis.axis_label_text_font_style = 'bold'
self.plot.x_range = DataRange1d(range_padding=0.0)
self.plot.grid.grid_line_alpha = 0.3
self.title = Paragraph(text=TITLE)
return column(self.title, self.plot)
示例3: make_plot
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DataRange1d [as 别名]
def make_plot(self, dataframe):
self.source = ColumnDataSource(data=dataframe)
self.plot = figure(
x_axis_type="datetime", plot_width=400, plot_height=300,
tools='', toolbar_location=None)
vbar = self.plot.vbar(
x='date', top='prcp', width=1, color='#fdae61', source=self.source)
hover_tool = HoverTool(tooltips=[
('Value', '$y'),
('Date', '@date_readable'),
], renderers=[vbar])
self.plot.tools.append(hover_tool)
self.plot.xaxis.axis_label = None
self.plot.yaxis.axis_label = None
self.plot.axis.axis_label_text_font_style = 'bold'
self.plot.x_range = DataRange1d(range_padding=0.0)
self.plot.grid.grid_line_alpha = 0.3
self.title = Paragraph(text=TITLE)
return column(self.title, self.plot)
示例4: __init__
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DataRange1d [as 别名]
def __init__(self, chart):
self._chart = chart
self._y_range_name = 'second_y'
self._chart.figure.extra_y_ranges = {
self._y_range_name: DataRange1d(bounds='auto')
}
# Add the appropriate axis type to the figure.
axis_class = LinearAxis
if self._chart._second_y_axis_type == 'log':
axis_class = LogAxis
self._chart.figure.add_layout(
axis_class(y_range_name=self._y_range_name), 'right')
self._y_axis_index = 1
self._y_range = self._chart.figure.extra_y_ranges[self._y_range_name]
self._chart.style._apply_settings('second_y_axis')
示例5: create_stock
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DataRange1d [as 别名]
def create_stock(cls, source):
# xdr1 = DataRange1d(sources=[source.columns("x")])
# ydr1 = DataRange1d(sources=[source.columns("y")])
# plot1 = figure(title="Outliers", x_range=xdr1, y_range=ydr1, plot_width=650, plot_height=400)
stock_plot = figure(title="", plot_width=650, plot_height=400)
# stock_plot.tools.append(TapTool(plot=stock_plot))
# stock_plot.line(x="x", y="values", size=12, color="blue", line_dash=[2, 4], source=source)
return stock_plot
# plot1.scatter(x="x", y="y", size="size", fill_color="red", source=source)
示例6: plot_volume
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DataRange1d [as 别名]
def plot_volume(self, data: bt.AbstractDataBase, alpha=1.0, extra_axis=False):
"""extra_axis displays a second axis (for overlay on data plotting)"""
source_id = FigureEnvelope._source_id(data)
self._add_columns([(source_id + 'volume', np.float64), (source_id + 'colors_volume', np.object)])
kwargs = {'fill_alpha': alpha,
'line_alpha': alpha,
'name': 'Volume',
'legend_label': 'Volume'}
ax_formatter = NumeralTickFormatter(format=self._scheme.number_format)
if extra_axis:
source_data_axis = 'axvol'
self.figure.extra_y_ranges = {source_data_axis: DataRange1d(
range_padding=1.0/self._scheme.volscaling,
start=0,
)}
# use colorup
ax_color = convert_color(self._scheme.volup)
ax = LinearAxis(y_range_name=source_data_axis, formatter=ax_formatter,
axis_label_text_color=ax_color, axis_line_color=ax_color, major_label_text_color=ax_color,
major_tick_line_color=ax_color, minor_tick_line_color=ax_color)
self.figure.add_layout(ax, 'left')
kwargs['y_range_name'] = source_data_axis
else:
self.figure.yaxis.formatter = ax_formatter
vbars = self.figure.vbar('index', get_bar_width(), f'{source_id}volume', 0, source=self._cds, fill_color=f'{source_id}colors_volume', line_color="black", **kwargs)
# make sure the new axis only auto-scales to the volume data
if extra_axis:
self.figure.extra_y_ranges['axvol'].renderers = [vbars]
self._hoverc.add_hovertip("Volume", f"@{source_id}volume{{({self._scheme.number_format})}}", data)
示例7: plot_parallel
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DataRange1d [as 别名]
def plot_parallel(
ax, diverging_mask, _posterior, var_names, figsize, backend_config, backend_kwargs, show
):
"""Bokeh parallel plot."""
if backend_config is None:
backend_config = {}
backend_config = {
**backend_kwarg_defaults(
("bounds_x_range", "plot.bokeh.bounds_x_range"),
("bounds_y_range", "plot.bokeh.bounds_y_range"),
),
**backend_config,
}
if backend_kwargs is None:
backend_kwargs = {}
backend_kwargs = {
**backend_kwarg_defaults(("dpi", "plot.bokeh.figure.dpi"),),
**backend_kwargs,
}
dpi = backend_kwargs.pop("dpi")
if ax is None:
backend_kwargs.setdefault("width", int(figsize[0] * dpi))
backend_kwargs.setdefault("height", int(figsize[1] * dpi))
ax = bkp.figure(**backend_kwargs)
non_div = list(_posterior[:, ~diverging_mask].T)
x_non_div = [list(range(len(non_div[0]))) for _ in range(len(non_div))]
ax.multi_line(
x_non_div, non_div, line_color="black", line_alpha=0.05,
)
if np.any(diverging_mask):
div = list(_posterior[:, diverging_mask].T)
x_non_div = [list(range(len(div[0]))) for _ in range(len(div))]
ax.multi_line(x_non_div, div, color="lime", line_width=1, line_alpha=0.5)
ax.xaxis.ticker = FixedTicker(ticks=list(range(len(var_names))))
ax.xaxis.major_label_overrides = dict(zip(map(str, range(len(var_names))), map(str, var_names)))
ax.xaxis.major_label_orientation = np.pi / 2
ax.x_range = DataRange1d(bounds=backend_config["bounds_x_range"], min_interval=2)
ax.y_range = DataRange1d(bounds=backend_config["bounds_y_range"], min_interval=5)
show_layout(ax, show)
return ax
示例8: plot
# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import DataRange1d [as 别名]
def plot(xLabel='x',yLabel='y',*args):
from bokeh.models import DataRange1d, Plot, LinearAxis, Grid
from bokeh.models import PanTool, WheelZoomTool
xdr = DataRange1d()
ydr = DataRange1d()
plot = Plot(x_range=xdr, y_range=ydr, min_border=80)
extra = list()
if type(xLabel) is not str and type(yLabel) is not str:
extra.append(xLabel)
extra.append(yLabel)
xLabel = 'x'
yLabel = 'y'
elif type(xLabel) is not str:
extra.append(xLabel)
xLabel = 'x'
elif type(yLabel) is not str:
extra.append(yLabel)
yLabel = 'y'
args = extra+list(args)
for renderer in args:
if type(renderer) is not list:
plot.renderers.append(renderer)
else:
plot.renderers.extend(renderer)
#axes
xaxis = LinearAxis(axis_label=xLabel)
plot.add_layout(xaxis, 'below')
yaxis = LinearAxis(axis_label=yLabel)
plot.add_layout(yaxis, 'left')
#add grid to the plot
#plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
#plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))
#interactive tools
plot.add_tools(PanTool(), WheelZoomTool()) #, SaveTool())
return plot