简体   繁体   English

使用matplotlib使用箭头散点图

[英]Scatter plot with arrows using matplotlib

I'm trying to make a scatter plot in matplotlib with arrows coming out of the points to indicate upper limits. 我正在尝试在matplotlib中绘制散点图,并从这些点出来的箭头表示上限。 To this end I've done the following, 为此,我做了以下工作:

arrow = u'$\u2193$'
ax.plot(x, y, linestyle='none', markersize=20, marker=arrow)
ax.plot(x, y, linestyle='none', markersize=10, marker='o')

However, I'm not totally satisfied with the results - 但是,我对结果并不完全满意-

这是结果

I'd like the arrows to come out of the middle of the points. 我希望箭头从要点中间出来。 So that point+arrow looks more like a single shape. 因此,该点+箭头看起来更像是单个形状。 Is there a way to do this? 有没有办法做到这一点?

Thanks! 谢谢!

you can do this with quiver . 你可以用quiver方式做到这一点。 It takes position and direction data to make plots full of arrows. 它需要位置和方向数据才能使绘图充满箭头。 But they'll start at the x,y rather than being centered (as you found in plot) 但是它们将从x,y开始,而不是居中(如在图中所见)

x=[4.0,7.0,4.5]
y=[3.0,1.0,5.5]
u=[0,0,0]
v=[1,1,1]
fig, ax = subplots()
ax.quiver(x,y,u,v)
ax.scatter(x,y,color='k')
ax.axis([0,10,0,10])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM