simPlot.py 文件源码

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

项目:anime_recs 作者: Cpierse 项目源码 文件源码
def bokeh_scatter_plot(tsne_df):
    output_file("results\\Anime_similarity.html")
    # Prep plot
    plot_anime_sim = bp.figure(plot_width=700, plot_height=600, title="Anime Similarity plotted with tSNE",
        tools="pan,wheel_zoom,box_zoom,reset,hover,previewsave,tap",
        x_axis_type=None, y_axis_type=None, toolbar_location="below",
        toolbar_sticky=False)
    # Plotting the anime data
    plot_anime_sim.scatter(x='x', y='y', source=tsne_df)
    # Handle hover tools
    hover = plot_anime_sim.select(dict(type=HoverTool))
    hover.tooltips={"Anime":"@anime_name [@rating]"}
    # Add ability to click links:
    url = "http://www.myanimelist.net/anime/@anime_id"
    taptool = plot_anime_sim.select(type=TapTool)
    taptool.callback = OpenURL(url=url)
    # Show the file:
    show(plot_anime_sim)

    script, div = components(plot_anime_sim)
    with open("results\\sim_script.js", "w") as text_file:
        text_file.write(script[37:-10])
    with open("results\\sim_html.html", "w") as text_file:
        text_file.write(div)

#%% Main code:
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号