[英]Label for point in plots in 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.我试图在我拥有的 matplotlib 散点图中的点上放置一些数据标签。 I was trying to imitate the solution here:我试图模仿这里的解决方案:
Is there a matplotlib equivalent of MATLAB's datacursormode? 是否有与 MATLAB 的 datacursormode 等效的 matplotlib?
within def __call__(self, event):
I get a failure at line:在def __call__(self, event):
我在行中失败:
xdata, ydata = event.artist.get_data()
AttributeError: 'CircleCollection' object has no attribute 'get_data'
Looking to the docs here: http://matplotlib.sourceforge.net/api/artist_api.html#module-matplotlib.artist在这里查看文档: http : //matplotlib.sourceforge.net/api/artist_api.html#module-matplotlib.artist
I see no method get_data(
) for Artist.我看不到 Artist 的get_data(
) 方法。 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?如果是这样,有人知道如何获得等效的电话吗?
If you look at the rest of the code in __call__
you'll see xdata
and ydata
are never used.如果您查看__call__
中的其余代码,您将看到从未使用过xdata
和ydata
。 You can simply delete the line您可以简单地删除该行
xdata, ydata = event.artist.get_data()
and the rest of Joe's beautiful code works just fine.乔的其余漂亮代码工作得很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.