在散点图中将值绘制为符号的最简单方法?
在回答我之前关于修复 4D 数据散点图像的色彩空间的问题时,Tom10 建议将值绘制为符号,以便仔细检查我的数据。一个好主意。我过去运行过一些类似的演示,但我一生都找不到我记得的演示非常简单。
那么,将数值绘制为散点图中的符号(而不是“o”)的最简单方法是什么? Tom10 建议 plt.txt(x,y,value) - 这是许多示例中使用的实现。然而,我想知道是否有一种简单的方法可以从我的数字数组中评估“价值”?可以简单地说: str(valuearray) 吗?
您是否需要一个循环来评估绘图的值,如 matplotlib 演示部分中针对 3D 文本散点的建议情节?
他们的示例生成:
(来源:sourceforge.net)
但是,他们'在评估位置以及根据数据更改文本方向方面正在做一些相当复杂的事情。那么,有没有一种可爱的方法来绘制 x,y,C 数据(其中 C 是通常被视为绘图数据中的颜色的值 - 但我希望制作符号)?
再说一遍,我认为我们对此有一个公平的答案 - 我只是想知道是否有更简单的方法?
In an answer to an earlier question of mine regarding fixing the colorspace for scatter images of 4D data, Tom10 suggested plotting values as symbols in order to double-check my data. An excellent idea. I've run some similar demos in the past, but I can't for the life of me find the demo I remember being quite simple.
So, what's the easiest way to plot numerical values as the symbol in a scatter plot instead of 'o' for example? Tom10 suggested plt.txt(x,y,value)- and that is the implementation used in a number of examples. I however wonder if there's an easy way to evaluate "value" from my array of numbers? Can one simply say: str(valuearray) ?
Do you need a loop to evaluate the values for plotting as suggested in the matplotlib demo section for 3D text scatter plots?
Their example produces:
(source: sourceforge.net)
However, they're doing something fairly complex in evaluating the locations as well as changing text direction based on data. So, is there a cute way to plot x,y,C data (where C is a value often taken as the color in the plot data- but instead I wish to make the symbol)?
Again, I think we have a fair answer to this- I just wonder if there's an easier way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我见过的最简单的方法是:
另外,顺便说一句,您建议使用 str(valarray) ,正如您可能已经注意到的那样,这不起作用。要将数字数组转换为字符串序列,您可以使用
获取 numpy 数组,或者
获取 Python 列表。但即使将 valarray 作为正确的字符串序列,plt.text 也不会迭代其输入。
The easiest way I've seen to do this is:
Also, btw, you suggested using str(valarray), and this, as you may have noticed doesn't work. To convert an array of numbers to a sequence of strings you could use
to get a numpy array, or,
to get a Python list. But even with valarray as a proper sequence of strings, plt.text won't iterate over it's inputs.