Zoom and have cursor for a matplotlib plot within iPython

半城伤御伤魂 提交于 2019-12-11 16:37:37

问题


Within Google-colaboratory, I cannot use matplotlib. use(TkAgg).

The possibility that it offers to me is though very helpful:

I can zoom in my plot interactively and also get a cursor that shows me the present values of x and y where my mouse is hovering over.

Is there anything similar within iPython / Jupyter that has a similar functionality?


回答1:


With these snippet, both zooming and the hovered mouse x/y cursor works in 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()


来源:https://stackoverflow.com/questions/54670637/zoom-and-have-cursor-for-a-matplotlib-plot-within-ipython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!