Just like what @ImportanceOfBeingErnest commented on your question, each time you run pp.plot()
, it will plot one more line on the same figure if you did not specify which figure to plot on.
To prevent this ambiguity You might want to follow @Lorran Sutter's suggestion or start using objects in matplotlib, then your code will become:
fig1 = pp.figure() #Creating new figure
ax1 = fig1.add_subplot(111) #Creating axis
ax1.set_title("Szekeres Polynomials")
ax1.plot([1,2,3], [8,5,4], '-', label='xxxabc' )
ax1.legend(loc='best', shadow=True)
fig1.savefig('TMPxxx.eps', format='eps', dpi=600)
This ensures every new plot is on a new figure, not plotting on the previous figure.
Benefits of using objects
Plotting graph in this way not only solves your problem, but also allows you do advanced plots and save multiple figure without confusion.
For example, when plotting three figures and each of the figure contains several subplots inside:
fig = pp.figure() #Creating the first figure
ax = fig.add_subplot(111)
ax.set_title("Szekeres Polynomials")
ax.plot([1,2,3], [8,5,4], '-', label='xxxabc' )
ax.legend(loc='best', shadow=True)
fig.savefig('TMPxxx.eps', format='eps', dpi=600)
fig1 = pp.figure() #Creating the second figure
ax1 = fig1.add_subplot(121)
ax1.set_title("Szekeres Polynomials")
ax1.plot([1,2,3], [8,5,4], '-', label='xxxabc' )
ax1.legend(loc='best', shadow=True)
ax2 = fig1.add_subplot(122)
ax2.set_title("Second Szekeres Polynomials")
ax2.plot([3,9,10], [10,15,20], '-', label='xxx' )
ax2.legend(loc='best', shadow=True)
fig1.savefig('TMPxxx2.eps', format='eps', dpi=600)
fig2 = pp.figure() #Creating the third figure
ax21 = fig2.add_subplot(131)
ax21.set_title("hahah")
ax21.plot([1,2,3], [1,2,3], '-', label='1', c='r')
ax21.legend(loc='best', shadow=True)
ax22 = fig2.add_subplot(132)
ax22.set_title("heheh")
ax22.plot([1,2,3], [-1,-2,-3], '-', label='2', c='b')
ax22.legend(loc='best', shadow=True)
ax23 = fig2.add_subplot(133)
ax23.set_title("hohoho")
ax23.plot([1,2,3], [2**2,4**2,6**2], '-', label='3', c='g' )
ax23.legend(loc='best', shadow=True)
fig2.savefig('graph2.eps', format='eps', dpi=600)

You can easily adjust parameters each individual subplot and save the three figures without a single confusion.