使用APLpy进行gridspec绘图的问题

时间:2016-07-27 14:00:36

标签: python matplotlib grid astropy aplpy

因此,我试图使用APLpy绘制适合图像(相同的图像)和DS9区域文件提供的注释:

我的脚本如下:

import aplpy

import matplotlib
import matplotlib.pyplot as pyplot
import matplotlib.gridspec as gridspec

from astropy.io import fits

matplotlib.rc('xtick', labelsize=8)
matplotlib.rc('ytick', labelsize=8)
#matplotlib.rc('text', usetex=True)
#matplotlib.rcParams['xtick.direction'] = 'out'
#matplotlib.rcParams['ytick.direction'] = 'out'
matplotlib.rcParams['grid.alpha'] = 0.3

nullfmt = pyplot.NullFormatter()

fig = pyplot.figure(figsize=(26,12))

gridspec_layout = gridspec.GridSpec(1,2)
#gridspec_layout.update(hspace=0.0, wspace=0.005)

M33_galax = aplpy.FITSFigure('/Users/.../SDSS_g_c_rescale.fits', figure=fig, subplot=list(gridspec_layout[0].get_position(fig).bounds), dimensions=[0, 1], slices=[0])
M33_stars = aplpy.FITSFigure('/Users/.../SDSS_g_c_rescale.fits', figure=fig, subplot=list(gridspec_layout[1].get_position(fig).bounds), dimensions=[0, 1], slices=[0])
#dimensions=[0, 1], slices=[1]

M33_galax.show_regions('SDSS_galaxy_match.reg')
#M33_stars.show_regions('')

M33_galax.set_tick_labels_format(xformat='hh:mm:ss.ss',yformat='dd:mm:ss')
M33_galax.set_tick_labels_font(size='x-small')
M33_galax.axis_labels.set_ytext(r'$\delta\,,\mathrm{Dec}\,\mathrm{(J2000)}$')
M33_galax.axis_labels.set_xtext(r'$\alpha\,,\mathrm{RA}\,\mathrm{(J2000)}$')
M33_galax.axis_labels.set_font(size='small')
M33_galax.axis_labels.set_ypad(10)
M33_galax.axis_labels.set_xpad(10)
M33_galax.add_grid()
M33_galax.grid.set_alpha(0.1)

M33_stars.set_tick_labels_format(xformat='hh:mm:ss.ss',yformat='dd:mm:ss')
M33_stars.set_tick_labels_font(size='x-small')
M33_stars.axis_labels.set_ytext(r'$\delta\,,\mathrm{Dec}\,\mathrm{(J2000)}$')
M33_stars.axis_labels.set_xtext(r'$\alpha\,,\mathrm{RA}\,\mathrm{(J2000)}$')
M33_stars.axis_labels.set_font(size='small')
M33_stars.axis_labels.set_ypad(10)
M33_stars.axis_labels.set_xpad(10)
M33_stars.add_grid()
M33_stars.grid.set_alpha(0.1)

pyplot.show()

但是,我发现以下是输出:

enter image description here

有人知道我在哪里出错吗?

1 个答案:

答案 0 :(得分:1)

您需要使用show_grayscaleshow_colorscale来显示图片,例如:

M33_galax.show_grayscale()
相关问题