python - 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>
解决方案
我找到了解决方案:对于像我这样有问题的人,通过更改后端什么也没有发生:github.com/ipython/ipython/issues/9834:
运行这个:
ipython --pylab
在终端中,它显示了图表。这将启动 ipython matplotlib GUI 后端。
推荐阅读
- ios - 如何在模拟器 iOS 13 中使用暗模式?
- docker - 是否可以在 Dockerfile 中指定使用官方镜像作为基础?
- javascript - CSS/Js - 当换行符和元素位于第一个位置时隐藏元素并更改 css
- python - 任意深度嵌套循环
- django - 表单未在 Django Admin 上注册
- c++ - 静态类模板实例作为成员导致未解决的外部符号错误
- batch-file - FINDSTR 结果在文本 csv 中没有换行符
- reactjs - Wowza 与 react js
- node.js - 使用 Docker Compose 在 Docker 中运行 React 不起作用
- cython - 诗歌 + 狮身人面像 + Cython