1

I making an application to plot Airfoils profiles in matplotlib and I need to plot a number of profiles in the same subplot. I know how to add a fixed number of series, but not how to do it dynamically. My code for one profile is:

pts = d['AG17']

fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
ax.plot(pts[:, 0], pts[:, 1], '-r')
ax.grid()
plt.show()

and for example for two profiles something like

ax.plot(pts[:, 0], pts[:, 1], '-r', pts1[:, 0], pts1[:, 1], '-r')

but how do I do it for n numbers of profiles?

2
  • 2
    You can make several plot calls for a single subplot. Commented Sep 11, 2015 at 1:21
  • 2
    If you are making many LineCollection might also be useful to you Commented Sep 11, 2015 at 1:41

1 Answer 1

3

You could put the ax.plot calls in a for loop:

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.