Working on an Ising model simulation in Matplotlib and at the end I need to export a figure as an image and every image is coming back blank. I figure it has to do with the message <Figure size 640x480 with 0 Axes> but I cannot figure out what I need to do to fix that message or fix the problem of figures not exporting properly.
Here's the code for creating the plot. I looked at other stack overflow posts and attempted to fix the issue, such as adding axes manually or defining the figure or making sure everything was defined in the right order and nothing seemed to fix the problem.
M = 1000plot = np.zeros(M)fig = plt.figureax = plt.axes(xlim=(0, M), ylim=(-400,400))for x in range(M): plot[x] = xxarr = range(0, M)ax.plot(xarr, plot, 'r-')plt.ylabel("Magnetism")plt.xlabel("Steps")plt.show()plt.savefig("output_mplot.png")