hover_scatter.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:unblackboxing_webinar 作者: deepsense-ai 项目源码 文件源码
def scatterplot_text(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>
                <p>
                    @text
                </p>
            </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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号