如何确定绘图中正在使用哪个坐标系,以及如何指定要用于覆盖网格的坐标系?
from astropy.wcs import WCS
from astropy.io import fits
from astropy.utils.data import get_pkg_data_filename
import matplotlib.pyplot as plt
image_file = get_pkg_data_filename('tutorials/FITS-images/HorseHead.fits')
hdu = fits.open(image_file)[0]
wcs = WCS(hdu.header)
plt.subplot(projection=wcs)
plt.imshow(hdu.data, origin='lower')
plt.grid(color='white', ls='solid')
plt.show()
我该如何指定我想将银河(或赤道)坐标用于plt.grid
?
答案 0 :(得分:0)
您可以这样做:
from astropy.wcs import WCS
from astropy.io import fits
from astropy.utils.data import get_pkg_data_filename
import matplotlib.pyplot as plt
image_file = get_pkg_data_filename('tutorials/FITS-images/HorseHead.fits')
hdu = fits.open(image_file)[0]
wcs = WCS(hdu.header)
fig = plt.figure(figsize=(12,12))
plt.subplot(projection=wcs)
plt.imshow(hdu.data, origin='lower')
ax = fig.gca()
overlay = ax.get_coords_overlay('galactic')
overlay.grid(color='red', ls='dotted')
plt.show()
完成后here。 (没有检查其背后的数学。)