简体   繁体   English

matplotlib 图中点的标签

[英]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__中的其余代码,您将看到从未使用过xdataydata 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.

相关问题 matplotlib箱形图中的'label'属性有什么用? - What is the use of the 'label' property in matplotlib box plots? 使用matplotlib标注时间图中的点 - label a point in graph using matplotlib for timeseries 有什么方法可以使用matplotlib在boxplot中标记图? - Is there any way we label the plots in boxplot using matplotlib? 如何更改 matplotlib 图的日期时间刻度标签频率? - How to change the datetime tick label frequency for matplotlib plots? 点参数对 matplotlib 中的小提琴图有什么作用 - What does the point parameter do to Violin plots in matplotlib 在matplotlib中为散点图提供旋转的更快方法? - Faster way to provide rotation to scatter point plots in matplotlib? Matplotlib - 如何使线图直接跳转到数据点 - Matplotlib - How to make line plots jump directly to data point 在图例中使用线和点标记共享两个图的相同标签 - Sharing the same label for two plots with line and point markers in legend 如何根据python/matplotlib中的pandas df列名称/标签名称为箱线图指定标签颜色 - How to specify label colors for box plots based on pandas df column name/label name in python/matplotlib 散点图根据数据点 label 为 matplotlib 设置颜色和图例 - Scatterplot set color and legend based on data point label for matplotlib
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM