虽然@拉尔夫-HTP的答案是非常干净,并使用散射,据我所知道的标记的规模,以点数表示(见例如
here).此外,如果放大,自定义标记不会改变大小.
也许这就是你要找的东西.如果没有,使用单独的Rectangle对象也很有效.这允许您指定的宽度和高度的数据单元,而不是点,你可以放大如有必要,很容易应用旋转,以及,通过设置角度属性:
from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle
# Your data
a = ([126, 237, 116, 15, 136, 348, 227, 247, 106, 5, -96, 25, 146],
[117, 127, 228, 107, 6, 137, 238, 16, 339, 218, 97, -4, -105])
# Your scatter plot
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(a[0], a[1], color = 'red', s=10)
# Add rectangles
width = 30
height = 20
a_zipped = zip(*a)
for a_x, a_y in a_zipped:
ax.add_patch(Rectangle(xy=(a_x-width/2, a_y-height/2) ,width=width, height=height, linewidth=1, color='blue', fill=False))
ax.axis('equal')
plt.show()
结果:
注意:如果需要,您可以通过ax.get_children获得了Rectangle实例().