[Python] Overploting healpy gnomview with data points ignores the data points

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página