缩放并在iPython中使用光标绘制matplotlib图

时间:2019-02-13 12:50:34

标签: python matplotlib jupyter google-colaboratory

在Google协作范围内,我无法使用matplotlib. use(TkAgg)

它为我提供的可能性非常有用:

我可以交互地放大绘图,还可以得到一个光标,向我显示鼠标悬停的x和y的当前值。

iPython / Jupyter中是否有类似的功能?

1 个答案:

答案 0 :(得分:0)

有了这些代码段,缩放和鼠标X / Y鼠标悬停光标在Google Colab中都可以使用:

!pip install mpld3
!pip install "git+https://github.com/javadba/mpld3@display_fix"
import mpld3
from mpld3 import plugins
fig, ax = plt.subplots()

ax.plot(a, "-o", markersize=2)
plugins.connect(fig, plugins.MousePosition(fontsize=14))

mpld3.display()