I have this code to generate the partial sums of pi (this is the part which graphs it):
plt.figure(1)
plt.plot(piresults)
plt.ylabel('value of calculated pi')
plt.xlabel('number of fractions calculated')
piresults2=[]
for result in piresults:
piresults2.append(math.fabs((result-math.pi)/math.pi))
plt.figure(2)
plt.plot(piresults2)
plt.ylim(0,1)
plt.ylabel('error %')
plt.xlabel('number of fractions calculated')
plt.show()
But my problem is the plots dont appear at the same time
I was expecting the two plots to appear alongside each other after only using plt.show() at the end and making the figures separate. But that's not happening? They appeared separately and i had to close one to get the other
If they're popping up as separate windows, you could draw two plots on a single figure/window instead.
Use
plt.subplots()to create a figure that has multiple subplots (axes). Select each subplot in turn (axes[0], thenaxes[1]) to plot on.