【发布时间】:2022-01-18 05:44:45
【问题描述】:
我在箭袋图中绘制了几个箭头,我想知道是否有办法用颜色填充箭头之间的形状。 箭袋图如下所示:
import numpy as np
import matplotlib.pyplot as plt
theta = np.linspace( 0 , 2 * np.pi , 40 )
R = 5.0
x = R * np.cos( theta )
y = R * np.sin( theta )
m2_x = 9.0
m2_y = 9.0
u = -(x - m2_x)/((m2_x - x)**2 + (m2_y - y)**2)**2
v = -(y - m2_y)/((m2_x - x)**2 + (m2_y - y)**2)**2
fig, ax = plt.subplots(figsize=(7,7))
ax.quiver(x,y,u,v, headwidth=2, headlength=5, width=0.005)
ax.set_xlim((-20,20))
ax.set_ylim((-20,20))
我想用颜色填充箭头所描绘的圆形,或者至少用一条线连接箭头。看起来应该很简单,但我还没有找到。
【问题讨论】:
-
使用
ax.plot(x+3000*u,y+3000*v)似乎有效,但我不知道为什么比例因子应该是3000。我的直觉是它与您正在使用的xlim和ylim有关(更多信息here)
标签: python matplotlib