我绘制散点图由以下代码:
import matplotlib.pyplot as plt
x = [2,4,6]
y = [1,3,7]
r = [650,890,320]
clr = ['r','b','g']
bubble_id = ['C0','C1','C2']
H0 = plt.scatter(x,y,s=r,c=clr)
![](https://www.manongdao.com/static/images/pcload.jpg)
然后我想'set_gid()'
的三个气泡为'C0', 'C1' ,'C2'
分别。 怎么做 ? 作为H0
是一个单独的对象<matplotlib.collections.PathCollection object at 0x0ADA6D30>
,我不知道如何打破H0和H0找到的三个“水泡子”。 感谢您的提示。
所以,我知道这可能不是最有效的解决方案,但如何循环?
import matplotlib.pyplot as plt
import itertools as it
X = [2,4,6]
Y = [1,3,7]
radius = [650,890,320]
clr = ['r','b','g']
bubble_id = ['C0','C1','C2']
ax = plt.subplot(111)
for x, y, r, c, id in it.izip(X, Y, radius, clr, bubble_id):
ax.scatter(x,y,s=r,c=c, gid=id)
在视觉上给人同样的情节。
在IPython中我已经给看看PathCollection
方法,它看起来像有非同小可的方式从中走出单一的补丁。