Saving a Python plot as a FITS file

Good afternoon, for one of my projects, I am trying to save a Python plot (using matplotlib and numpy) as a FITS file. However, when I right-click on the image to try and save it, the only option available is to store data as a .PNG file. Is there anyway to save this image as a FITS file? I tried searching online and found that one could do so if you are simply editing an existing FITS file.

From what I understand the FITS standard is not designed to save out images from a plot. If you want to store the array data that forms the main part of your image, you can save that as a FITS file. See FITS File Handling (astropy.io.fits) — Astropy v5.1

Can I ask why you want an image as a FITS file?

1 Like