0

I'm solving a PDE and plotting solutions at each step in a loop. However, when I try and run the loop to produce three plots, all the plots end up on the same image. What should I put after each scatter plot so that this works? My code looks like this...

for n in range(5,10):
    
    #make empty list
    P_vals_x = []
    P_vals_y = []
    P_vals_z = []
    
   
   

     #Store P values varying y, x and z held equal to 1
    for n in  np.linspace(y0,y1,xyz_fixed_density):
     P_vals_y.append(u(1,n,1))


     #Store P values varying z, x and y held equal to 1
    


   

    
     plt.scatter(np.linspace(x0,x1,xyz_fixed_density),P_vals_x,s=3)
     plt.legend(L_vals)
     plt.xlabel('$x$')
     plt.ylabel('$P(L,x,1,1)$')
     plt.savefig('P_vs_x.png')
    

     plt.scatter(np.linspace(y0,y1,xyz_fixed_density),P_vals_y,s=1,c='black')
     plt.legend(L_vals)
     plt.xlabel('$y$')
     plt.ylabel('$P(L,1,y,1)$')
     plt.savefig('P_vs_y.png')
    

    plt.scatter(np.linspace(z0,z1,xyz_fixed_density),P_vals_z,s=1,c='black')
    plt.legend(L_vals)
    plt.xlabel('$z$')
    plt.ylabel('$P(L,1,1,z)$')
    plt.savefig('P_vs_z.png')
    

plt.clf()
rami_salazar
  • 165
  • 1
  • 7

0 Answers0