Édi Leung
Édi Leung

Reputation: 19

drawing a map in python

I'm trying to make a really simple animation of a voyage around the milky way.

for k in range(7):
    Rs += k
    Zs += 0.01*k
    for i in range(len(B)):
        print 'i=',i
        for j in range(len(L)):
            MAP[i,j] = DensiteCol(L[j], B[i], 20., 1000.)

    plt.xlabel('l')
    plt.ylabel('b')
    plt.imshow(MAP)
    plt.show()
    #plt.savefig('Q8_'k'.jpg')

How can I save an image each time in the loop and save it as different names?

MAP[i,j] = DensiteCol(L[j], B[i], 20., 1000.)

In this case, is L the axe horizontal or B is?

Upvotes: 0

Views: 97

Answers (2)

paddyg
paddyg

Reputation: 2233

Sometimes it's useful to get the files in the right order so:

plt.savefig("Q8_{:04d}.jpg".format(k))

Upvotes: 3

sshashank124
sshashank124

Reputation: 32189

You can do it as follows:

plt.savefig('Q8_' + str(k) + '.jpg')

Upvotes: 1

Related Questions