天空区域上带有圆圈的散点图

问题描述 投票:0回答:1

我正在尝试绘制天空区域上几个数据点的散点图,然后在图中添加一个圆圈。请注意,我不需要完整天空的图,而只需要数据点周围区域的图。数据点的坐标(以度为单位)为:

ra = np.array([248.3, 249.8, 250.2, 250.5, 250.5])
dec = np.array([68.8, 67.7, 65.7, 72.2, 63.3])

圆心应位于

ra1 = 270
dec1= 66

看起来这个包(因为我们需要考虑天空的曲率!)将是

astropy
regions
。但我就是无法让它发挥作用。这篇文章here几乎是我想要实现的目标,但它只适用于一个点,我不知道如何添加更多点。谢谢建议!

python matplotlib coordinates region astropy
1个回答
0
投票

使用链接的示例,您可以执行以下操作:

import numpy as np
import astropy.units as u
from gammapy.maps import RegionGeom
from astropy.coordinates import SkyCoord
from regions import CircleSkyRegion, PointSkyRegion

ra = np.array([248.3, 249.8, 250.2, 250.5, 250.5])
dec = np.array([68.8, 67.7, 65.7, 72.2, 63.3])
ra1, dec1 = 270, 66

region = RegionGeom(CircleSkyRegion(SkyCoord(ra=ra1, dec=dec1, unit='deg'), 10 * u.deg))
centers = [SkyCoord(ra=ra, dec=dec, unit='deg') for ra, dec in zip(ra, dec)]
points = [RegionGeom(PointSkyRegion(center=center)) for center in centers]

ax = region.plot_region()
for point in points:
    point.plot_region(ax=ax, facecolor="black", edgecolor="black",
        kwargs_point={"fillstyle": "full", "marker": "o"}
    )
ax.grid()

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.