matplotlib 图中点的标签 [英] Label for point in plots in matplotlib
问题描述
所以这是一个关于已发布解决方案的问题.我试图在我拥有的matplotlib散点图中的点上放置一些数据标签.我试图模仿这里的解决方案:
So this is sort of a question about a posted solution. I was trying to put some data labels on points in a matplotlib scatterplot I have. I was trying to imitate the solution here:
是否有与 MATLAB 的 datacursormode 等效的 matplotlib?
在 def __call __(自身,事件)内:
我在以下行失败:
xdata, ydata = event.artist.get_data()
AttributeError: 'CircleCollection' object has no attribute 'get_data'
在此处查看文档: http://matplotlib.sourceforge.net/api/artist_api.html#module-matplotlib.artist
我看不到 Artist 的方法 get_data(
).这只是已经过时的东西还是我错过了什么?如果有的话,有人知道如何获得等效呼叫吗?
I see no method get_data(
) for Artist. Is this just something that has been deprecated or did I miss something? If it has been, anyone know of how else to get an equivalent call?
推荐答案
如果您查看 __call__
中的其余代码,您将看到 xdata
和 ydata
从未使用过.您只需删除该行
If you look at the rest of the code in __call__
you'll see xdata
and ydata
are never used. You can simply delete the line
xdata, ydata = event.artist.get_data()
Joe 的其他漂亮代码运行良好.
and the rest of Joe's beautiful code works just fine.
这篇关于matplotlib 图中点的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!