I am running into a problem viewing images with astropy. Here is my code:
from astropy.io import fits
import matplotlib.pyplot as plt
hdu_list=fits.open("500m2deep.fit")
image_data=hdu_list[0].data
hdu_list.close()
plt.imshow(image_data,cmap='gray')
plt.show()
Opening the file works fine, I can display the entries of image_data
and alike. But the picture doesn't show if I use imshow
. It displays the following error:
C:\Python27\lib\site-packages\IPython\core\formatters.py:239: FormatterWarning: Exception in image/png formatter: FormatterWarning,
If I use, as suggested on some sites, %matplotlib
inline, or something similar, this error disappears, but no image shows at all, the program runs, terminates, no picture pops up. I also tried adding something like plt.figure(
) before imshow()
but that doesn't help either.
This happens if I use Spyder, Ipython, or Ipython Notebook. I am using the newest version of python(x,y) for all of this.
How can I display the pictures?