def scatterplot_vis(df, **kwargs):
plot_width = kwargs.get('plot_width',300)
plot_height = kwargs.get('plot_height',300)
size = kwargs.get('size',10)
hover = HoverTool(
tooltips="""
<div>
<div>
<img
src="@img_filepath" height="200" alt="@img_filepath" width="200"
style="float: left; margin: 0px 15px 15px 0px;"
border="2"
></img>
</div>
</div>
"""
)
p = figure(plot_width=plot_width, plot_height=plot_height,
toolbar_location = 'right',
tools='pan,box_zoom,wheel_zoom,reset,resize')
p.add_tools(hover)
df['label_color'] = df['label'].apply(lambda x: COLOR_PALETTE.as_hex()[int(x)])
source = ColumnDataSource(df)
circles = p.circle('x', 'y', size=size, source=source)
circles.glyph.fill_color = 'label_color'
output_notebook()
show(p)
hover_scatter.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录