绘图适合图像matplotlib.imshow以WCS作为x和y轴

2024-09-27 04:23:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道是否有人知道如何用python包绘制fits图像matplotlib.imshow使用相应的世界坐标系值,甚至可能是赤经或赤纬作为x和y值,而不是物理像素值,类似于本页的底图:http://astroplotlib.stsci.edu/page_images.htm

不幸的是,提供的脚本是在IDL中…我还不太精通。。。在

如果我概述一下我的gridspec布局,可能会有帮助:

fig = pyplot.figure(figsize=(11,11))

gridspec_layout = gridspec.GridSpec(3,3)
gridspec_layout.update(hspace=0.0, wspace=0.0)

hdulist_org_M33_UVM2 = fits.open('myfits.fits')
wcs = WCS(hdulist_org_M33_UVM2[0].header)

pyplot_2 = fig.add_subplot(gridspec_layout[2])

ax = WCSAxes(fig, [0.1, 0.1, 0.8, 0.8], wcs=wcs)

pyplot_2.add_axes(ax)

但运气不好。在

非常感谢。在


Tags: org图像addmatplotlibfig绘制axlayout
1条回答
网友
1楼 · 发布于 2024-09-27 04:23:01

一种解决方案可能是使用^{} parameter to ^{},并从gridspec获取边界。在

大致如下:

from matplotlib import pyplot
from matplotlib import gridspec
import aplpy

fig = pyplot.figure(figsize=(11, 11))
gridspec_layout = gridspec.GridSpec(3, 3)
gridspec_layout.update(hspace=0.0, wspace=0.0)
axes = fig.add_subplot(gridspec_layout[2])
m33 = aplpy.FITSFigure('wfpcii.fits', figure=fig,
                       subplot=list(gridspec_layout[2].get_position(fig).bounds),
                       # dimensions and slices are not normally necessary;
                       # my test-figure has 3 axes
                       dimensions=[0, 1], slices=[0])
print(dir(gridspec_layout[2]))
print(gridspec_layout[2].get_position(fig).bounds)
m33.show_colorscale()
pyplot.show()

不是很漂亮,但会有用的。如果我遇到了一种更简单的方法来将FITSFigure直接附加到一个轴上,我将修改这个答案或提出一个新的答案。在

相关问题 更多 >

    热门问题