【问题标题】:Matplotlib, Jupyter: Have annotation appearing when hovering over plotMatplotlib,Jupyter:悬停在绘图上时出现注释
【发布时间】:2017-01-21 11:57:04
【问题描述】:

我正在尝试使用 matplotlib 创建一个绘图,当悬停悬停图表的某些元素时会出现工具提示。我想在 Jupyter Notebook 中使用 python 3 执行此操作。

我已经尝试过这里提供的 sn-ps:

http://matplotlib.org/examples/event_handling/pick_event_demo.html
Possible to make labels appear when hovering over a point in matplotlib?
Is there a matplotlib equivalent of MATLAB's datacursormode?
Matplotlib basemap: Popup box

但它们都不起作用。该图显示但不是交互式的。 我尝试了有无魔法%matplotlib inline,但没有任何效果。 当然,我还修改了没有括号的打印语句。
是否有特定的命令或后端可用于在 Jupyter 中进行交互?

编辑: 使用 mpld3 的示例“有效”,但我宁愿坚持使用基本的 matplotlib。

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    我想你想要%matplotlib notebook。这将在笔记本中集成交互式绘图。

    【讨论】:

    • 是的,这就是解决方案。但是,您知道如何删除绘图左下角的平移/缩放工具和%matplotlib notebook 显示顶部的“数字”标题吗?它们令人分心和缺乏审美
    • 我不知道。我记得(模糊地)试图用这个后端删除工具栏但失败了。如果还没有的话,这值得在 SO 中提出自己的问题。
    猜你喜欢
    • 2020-01-23
    • 2022-12-02
    • 2011-12-16
    相关资源
    最近更新 更多