本文整理汇总了Python中bokeh.models.HoverTool.renderers方法的典型用法代码示例。如果您正苦于以下问题:Python HoverTool.renderers方法的具体用法?Python HoverTool.renderers怎么用?Python HoverTool.renderers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.models.HoverTool
的用法示例。
在下文中一共展示了HoverTool.renderers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_merged_benchmark
# 需要导入模块: from bokeh.models import HoverTool [as 别名]
# 或者: from bokeh.models.HoverTool import renderers [as 别名]
def plot_merged_benchmark(savefile, benchmarks, title, xaxis_type, yaxis_type,
save_prefix=""):
# Sort the benchmarks by device name
bmarks_sorted = sorted(benchmarks, key=lambda k: k['extra_data']['AF_DEVICE'])
benchmarks = bmarks_sorted
# configure the colors
colors = unique_colors()
assigned_colors = dict()
# configure the hover box
hover = HoverTool(
tooltips = [
("Device", "@device"),
("Benchmark", "@benchmark"),
("Backend", "@platform"),
("OS", "@os"),
("(x,y)", "(@x,@y)")
])
# configure the plot title and axis labels, use CDN for the data source
#bplt.output_file(save_prefix + savefile + ".html", title=title, mode='cdn')
bplt.output_file(save_prefix + savefile + ".html", title=title)
plot = bplt.figure(title=title, tools=[hover,'save,box_zoom,resize,reset'])
xlabel = ""
ylabel = ""
legend_location = "top_right"
# plot images/second vs. data size
scatter_renderers = list()
for benchmark in benchmarks:
bmark_name = benchmark['benchmark_name']
# Look up the color
device = benchmark['extra_data']['AF_DEVICE']
platform = benchmark['extra_data']['AF_PLATFORM']
operating_system = benchmark['extra_data']['AF_OS']
# key = device
key = bmark_name + device + platform
if key in assigned_colors:
color = assigned_colors[key]
else:
color = colors.next()
assigned_colors[key] = color
# extract benchmarks
x,xlabel,legend_location = format_data(benchmark, xaxis_type)
y,ylabel,legend_location = format_data(benchmark, yaxis_type)
# get the device name, override if necessary
if 'AF_LABEL' in benchmark['extra_data'].keys():
device = benchmark['extra_data']['AF_LABEL']
source = bplt.ColumnDataSource(
data = dict(x=x,y=y,
device=[device]*len(x),
benchmark=[bmark_name]*len(x),
platform=[platform]*len(x),
os=[operating_system]*len(x),
))
# Generate the legend, automatically add the platform if needed
# legend = device
legend = device + " (" + platform + ") " + bmark_name
# generate the plot
plot.line(x,y, legend=legend, color=color, line_width=2)
sr = plot.scatter('x', 'y', source=source, legend=legend, color=color,
fill_color="white", size=8)
scatter_renderers.append(sr)
hover = plot.select(HoverTool)
hover.renderers = scatter_renderers
plot.xaxis.axis_label = xlabel
plot.yaxis.axis_label = ylabel
plot.legend.location = legend_location
# save the plot
bplt.save(plot)
示例2: plot_benchmark
# 需要导入模块: from bokeh.models import HoverTool [as 别名]
# 或者: from bokeh.models.HoverTool import renderers [as 别名]
def plot_benchmark(savefile, benchmarks, title, xaxis_type, yaxis_type,
save_prefix=""):
show_backends = False
show_os = False
# Determine the number of backends
backends = list_recordTable_attribute(benchmarks, 'AF_PLATFORM')
if len(backends) > 1:
show_backends = True
operating_sys = list_recordTable_attribute(benchmarks, 'AF_OS')
if len(operating_sys) > 1:
show_os = True
# Sort the benchmarks by device name
bmarks_sorted = sorted(benchmarks, key=lambda k: k['extra_data']['AF_DEVICE'])
benchmarks = bmarks_sorted
# configure the colors
colors = unique_colors()
# configure the hover box
hover = HoverTool(
tooltips = [
("Device", "@device"),
("Backend", "@platform"),
("OS", "@os"),
("(x,y)", "(@x,@y)")
])
# configure the plot title and axis labels, use CDN for the data source
#bplt.output_file(save_prefix + savefile + ".html", title=title, mode='cdn')
bplt.output_file(save_prefix + savefile + ".html", title=title)
plot = bplt.figure(title=title, tools=[hover,'save,box_zoom,resize,reset'])
xlabel = ""
ylabel = ""
legend_location = "top_right"
# plot images/second vs. data size
scatter_renderers = list()
for benchmark in benchmarks:
# get the color we will use for this plot
color = colors.next()
# extract benchmarks
x,xlabel,legend_location = format_data(benchmark, xaxis_type)
y,ylabel,legend_location = format_data(benchmark, yaxis_type)
platform = benchmark['extra_data']['AF_PLATFORM']
# get the device name, override if necessary
device = benchmark['extra_data']['AF_DEVICE']
operating_system = benchmark['extra_data']['AF_OS']
if 'AF_LABEL' in benchmark['extra_data'].keys():
device = benchmark['extra_data']['AF_LABEL']
source = bplt.ColumnDataSource(
data = dict(x=x,y=y,
device=[device]*len(x),
platform=[platform]*len(x),
os=[operating_system]*len(x),
))
# Generate the legend, automatically add the platform if needed
legend = device
if show_os or show_backends:
legend += "( "
if show_os:
legend += operating_system + " "
if show_backends:
legend += platform + " "
if show_os or show_backends:
legend += ")"
# generate the plot
plot.line(x,y, legend=legend, color=color, line_width=2)
sr = plot.scatter('x', 'y', source=source, legend=legend, color=color,
fill_color="white", size=8)
scatter_renderers.append(sr)
hover = plot.select(HoverTool)
hover.renderers = scatter_renderers
plot.xaxis.axis_label = xlabel
plot.yaxis.axis_label = ylabel
plot.legend.location = legend_location
# save the plot
bplt.save(plot)