问题
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