我制作了一个在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[:, 1], '-r', pts1[:, 0], pts1[:, 1], '-r')
但是,如何对配置文件的n
数进行处理呢?
发布于 2015-09-11 00:43:53
您可以将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()
https://stackoverflow.com/questions/32513719
复制相似问题