如何在绘图中使用自定义 png 图像标记?
我想在散点图和折线图中使用客户标记。如何从 PNG 文件中制作自定义标记?
I would like to utilize customer markers in both scatter and line charts. How can I make custom marker out of a PNG file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不相信 matplotlib 可以自定义这样的标记。请参阅此处了解自定义级别,该级别远远低于您的需求。
作为替代方案,我编写了这个拼凑代码,它使用 matplotlib.image 将图像放置在线点位置。
产生:
I don't believe matplotlib can customize markers like that. See here for the level of customization, which falls way short of what you need.
As an alternative, I've coded up this kludge which uses
matplotlib.image
to place images at the line point locations.Produces:
继马克的回答之后。我只是想我应该添加一点,因为我尝试运行它,它执行我想要的操作,除了在图表上实际显示图标之外。也许 matplotlib 发生了一些变化。 已经四年了。
这行代码
看起来不起作用,但
确实有效。
Following on from Mark's answer. I just thought I would add to this a bit because I tried to run this and it does what I want with the exception of actually displaying the icons on the graph. Maybe something has changed with matplotlib. It has been 4 years.
The line of code that reads:
does not seem to work, however
does work.
另一个答案可能会在调整图形大小时导致问题。这是一种不同的方法,将图像定位在注释框中,这些注释框锚定在数据坐标中。
The other answer may lead to problems when resizing the figure. Here is a different approach, positionning the images inside annotation boxes, which are anchored in data coordinates.