我正在尝试使用astropy.io来显示开普数字:我尝试了网页http://learn.astropy.org/rst-tutorials/FITS-images.html?highlight=filtertutorials中所说的所有内容
In [1]: import matplotlib.pyplot as plt
In [2]: from astropy.io import fits
In [3]: import numpy as np
In [4]: from astropy.utils.data import download_file
In [5]: image_file = download_file('http://data.astropy.org/tutorials/FITS-image
...: s/HorseHead.fits', cache=True )
In [6]:
In [6]: hdu_list = fits.open(image_file)
In [7]: hdu_list.info()
Filename: /home/mahtab/.astropy/cache/download/py2/2c9202ae878ecfcb60878ceb63837f5f
No. Name Ver Type Cards Dimensions Format
0 PRIMARY 1 PrimaryHDU 161 (891, 893) int16
1 er.mask 1 TableHDU 25 1600R x 4C [F6.2, F6.2, F6.2, F6.2]
In [8]: image_data = hdu_list[0].data
In [9]: print(type(image_data))
<type 'numpy.ndarray'>
In [10]: print(image_data.shape)
(893, 891)
In [11]: plt.imshow(image_data, cmap='gray')
Out[11]: <matplotlib.image.AxesImage at 0x7fbd3f9f7c50>它为我提供了数据和信息,但没有显示我应该如何处理的图形:
Out[11]: <matplotlib.image.AxesImage at 0x7fbd3f9f7c50>发布于 2020-02-04 20:55:47
我找到了解决方案:对于像我这样有问题的人,通过更改后台什么都不会发生: github.com/ipython/ipython/issues/9834:
运行以下命令:
ipython --pylab在终端中,它显示了曲线图。这将启动ipython matplotlib GUI后端。
https://stackoverflow.com/questions/60017219
复制相似问题