3

I am trying to plot a HEALPix mask using healpy, e.g.:

    import healpy as hp
    import matplotlib
    from pylab import *

    # Read in mask...
    # ...

    # Plot mask
    fig = figure(figsize=(12,8))
    ax = hp.projaxes.HpxMollweideAxes(fig,[0.1,0.1,0.8,0.8],rot=(180.0,0.0,0.0),coord=["C"])
    fig.add_axes(ax)
    ax.projmap(mask,nest=False)
    hp.visufunc.graticule()
    show()

However, I would like to display the RA/Dec (phi/theta) tick labels to the axes. Does anybody know how to do this?

Oh, also, does anybody have python code to plot a HEALPix mask on a hammer projection plot?

Thanks!

Alex

aim
  • 657
  • 2
  • 12
  • 26
  • I realise that I could have plotted the mask simply using healpy.visufunc.mollview function, but I would like to add other datasets to this plot as scatter points and I think using projaxes provides a scatter function to do this. – aim Jun 23 '14 at 16:04

2 Answers2

2

No way to do it right now with healpy

There is an open issue on healpy about this: https://github.com/healpy/healpy/issues/19.

An alternative is to plot a map directly using matplotlib:

https://github.com/zonca/paperplots/blob/master/python/scripts/PlanckFig_map.py

Andrea Zonca
  • 8,378
  • 9
  • 42
  • 70
  • 1
    Thanks! I've been able to adapt your script. Now I can include tick labels AND choose alternative projections! – aim Jun 23 '14 at 20:40
1

I am not sure if this is what the author wanted, but in the meantime the healpy team has made it possible to display the tick labels (graticule labels) and a few more things with from healpy.newvisufunc import projview, see here.

From the reference above - code and the figure it creates:

# Hammer projection, override axis tick labels
projview(
    m,
    coord=["G"],
    graticule=True,
    graticule_labels=True,
    unit=r"cbar label",
    xlabel="longitude",
    ylabel="latitude",
    cb_orientation="vertical",
    min=-0.05,
    max=0.05,
    latitude_grid_spacing=30,
    projection_type="hammer",
    title="Hammer projection",
    custom_xtick_labels=["A", "B", "C", "D", "E"],
    custom_ytick_labels=["F", "G", "H", "I", "J"],
);

enter image description here

NeStack
  • 1,739
  • 1
  • 20
  • 40