Python 向matplotlib动态添加系列
我正在matplotlib中制作一个绘制翼型剖面的应用程序,我需要在同一个子地块中绘制多个剖面。我知道如何添加固定数量的系列,但不知道如何动态添加。我的个人资料代码为:Python 向matplotlib动态添加系列,python,matplotlib,Python,Matplotlib,我正在matplotlib中制作一个绘制翼型剖面的应用程序,我需要在同一个子地块中绘制多个剖面。我知道如何添加固定数量的系列,但不知道如何动态添加。我的个人资料代码为: pts = d['AG17'] fig = plt.figure() ax = fig.add_subplot(111, aspect='equal') ax.plot(pts[:, 0], pts[:, 1], '-r') ax.grid() plt.show() 例如,对于两个配置文件 ax.plot(pts[:, 0]
pts = d['AG17']
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
ax.plot(pts[:, 0], pts[:, 1], '-r')
ax.grid()
plt.show()
例如,对于两个配置文件
ax.plot(pts[:, 0], pts[:, 1], '-r', pts1[:, 0], pts1[:, 1], '-r')
但是,如何为
n
数量的配置文件执行此操作?您可以将ax.plot
调用放入for循环中:
profiles = ['AG17','AG18','AG19', ... , etc.] # I'm guessing at your profile names!
linestyles = ['r-','b--','g:', ..., etc.] # Use this if you want different colors or linestyles for each profile
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
for prof, ls in zip(profiles,linestyles):
pts = d[prof]
ax.plot(pts[:, 0], pts[:, 1], ls)
ax.grid()
plt.show()
您可以对单个子地块进行多个
plot
调用。如果要进行多个LineCollection
调用,也可能对您有用