views:

327

answers:

1

I am just starting to use 'matplotlib' and I have hit upon 2 major roadblocks, which I can't seem to work around from the docs/examples,etc: Here is Python source:

#!/usr/bin/python
import matplotlib
matplotlib.use('Agg')

import matplotlib.pyplot as plt
for i in range(0,301):

    print "Plotting",i

    # Reading a single column data file
    l=plt.plotfile("gen"+str(i))

    plt.xlabel('Population')
    plt.ylabel('Function Value')
    plt.title('Generation'+str(i))
    plt.axis([0,500,0,180])

    plt.plot()

    if len(str(i)) == 1:
        plt.savefig("../images/plot00"+str(i)+".png")
    if len(str(i)) == 2:
        plt.savefig("../images/plot0"+str(i)+".png")
    if len(str(i)) == 3:
        plt.savefig("../images/plot"+str(i)+".png")

    plt.clf()
  1. Doubt 1: As you can see, I am basically clearing the plot and then saving the new plot every time. I want to keep the range of the Y-axis constant and I am trying to do it via "plt.axis([0,500,0,180])". But it doesn;t seem to work and it is automatically set everytime.
  2. Doubt 2: Instead of obtaining the default plot in which the points are joined by continuous lines, I would prefer to obtain a plot of say, '*'. How would I do that?
+2  A: 
unutbu
Cool! Thanks a ton. I was fearing that I might need to do something with the Figure class etc. Thanks a bunch!
Amit