首页 > 解决方案 > astropy.io 没有显示数字

问题描述

我正在尝试与 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>

标签: python

解决方案


我找到了解决方案:对于像我这样有问题的人,通过更改后端什么也没有发生:github.com/ipython/ipython/issues/9834:

运行这个:

ipython --pylab

在终端中,它显示了图表。这将启动 ipython matplotlib GUI 后端。


推荐阅读