我想用箭头描绘一系列风向,并确定一定的大小,具体取决于风的强度。但是我在循环中所能做的就是在另一个箭头上画一个箭头。我只想每个情节一个箭头。
这是我的代码,将ax = plt.axes()移出循环无济于事。
import numpy as np
import matplotlib.pyplot as plt
import math
Dir2013 =np.loadtxt('H:/EMBC/Thesis/Data/Wind/winddir_2013_Westhinder.txt') #wind direction
Vel2013 =np.loadtxt('H:/EMBC/Thesis/Data/Wind/windvel_2013_Westhinder.txt') #wind velocity
Start=[]
Stop=[]
kl=[]
kl2=[]
for i in range (0, len(Dir2013)):
if Dir2013[i][5]==39:
Start=i
if Dir2013[i][5]==154:
Stop=i
if Vel2013[i][6]<0:
Vel2013[i][6]==0
kl.append(i)
kl2.append(Vel2013[i][6])
parts=(len(Dir2013)/365)
Steps=(Stop-Start)/parts
for i in range (Start, Stop,int(parts)):
ax = plt.axes()
ax.set_xlim(left=-3, right=3, emit=True, auto=False)
ax.set_ylim(bottom=-3, top=3, emit=True, auto=False)
ax.spines['bottom'].set_color('k')
ax.spines['top'].set_color('k')
ax.spines['left'].set_color('k')
ax.spines['right'].set_color('k')
ax.tick_params(axis='x', colors='k')
ax.tick_params(axis='y', colors='k')
x0, y0 = 0, 0
radius = Vel2013[i][6]*0.1
angle_rad = int(Dir2013[i][6])* math.pi / 180 # degrees to radians
head_length = 0.08
ax.arrow(x0, y0,
(radius - head_length) * math.cos(angle_rad),
(radius - head_length) * math.sin(angle_rad),
head_width=0.08, head_length=head_length, fc='k', ec='k',width=0.01)
plt.savefig('ArrowAa%d' %i)
plt.show()
如何在每个图中仅绘制一个箭头?