最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Overploting healpy gnomview with data points ignores the data points - Stack Overflow

programmeradmin2浏览0评论

I am trying to create a figure in Python containing subplots with a gnomview map inside and data points overplotted. I am using this code:

import healpy as hp
import matplotlib.pyplot as plt
import numpy as np

nside = 32
npix = hp.nside2npix(nside)
rot = [0, 0]
xsize = 500
reso = 1.0

fig, axs = plt.subplots(1, 3, figsize=(15, 5))

data = np.random.randn(npix)

num_points = 100
ra = np.random.uniform(0, 360, num_points)
dec = np.random.uniform(-90, 90, num_points)

for i, ax in enumerate(axs):
    hp.gnomview(data, rot=rot, xsize=xsize, reso=reso, sub=(1, 3, i + 1), fig=fig, notext=True, cbar=False)

    hp.projscatter(ra, dec, lonlat=True, coord='G')


plt.tight_layout()

plt.show()

This creates the figure with subplots showing the gnomview in each of them, but the scattered data points are not displayed. I also tried substituting the line hp.projscatter(...) with ax.scatter(ra, dec, marker='o', color='red', s=10), but again no points are being shown. What am I doing wrong? Is there an alternative way to plot data points on top of healpy gnomview subplots?

发布评论

评论列表(0)

  1. 暂无评论