I have a program that follows closely the link above and I want to saves the FITS matplotlib image as a jpeg file so when I work with my real FITS files later on, I can save them as jpegs.
I tried to save it the usual way:
plt.savefig("output.jpg")
However, after doing this, I find that the output does not look anything like the image
[![It is a completely blank image][1]][1]
...
print(image_data.shape)
plt.imshow(image_data, cmap='gray')
plt.colorbar()
plt.savefig("output.jpg") #save as jpg
This order (without plt.figure()) works here. What are you using to run it? If it’s something like Jupyter, maybe it does implicit plt.show() and clears it?