2

I want to plot many subplots in one figure using healpy. How to:

  1. Set the position of the colorbar?
  2. Set the tick and ticklabel of colorbar?
  3. Set the position and size of the subplots?

I want to generate a plot such as figure 1, which is plotted in MATLAB, based on general coordinates

matlabplot

Right now, I only plot it as follows using healpy: Figure 2, based on healpy

A similar code to produce figure 3 (similar to figure2) is as follow:

import numpy as np
import healpy as hp

degree = 4
nside = 2**degree
num_Pixel = hp.nside2npix(nside)

m = np.arange(num_Pixel)

margins = [[0.02,0,0,0],[0.01,0,0,0],[0.01,0,0.01,0],
        [0.02,0,0,0],[0.01,0,0,0],[0.01,0,0.01,0],
        [0.02,0.05,0,0],[0.01,0.05,0,0],[0.01,0.05,0.01,0]]

title = [
    'Equinox', 'Jun. Solstice', 'Dec. Solstice',
    '','','','','','']

for ifig in range(1,10):
    if ifig < 7:
       hp.cartview(
           m, sub=330+ifig, margins=margins[ifig1],
           cbar=False, title=title[ifig-1])
    else:
       hp.cartview(
           m, sub=330+ifig, margins=margins[ifig-1],
           cbar=True, title=title[ifig-1])

The code produced the figure 3 figure 3

Seanny123
  • 8,776
  • 13
  • 68
  • 124

1 Answers1

1

I'm afraid healpy doesn't come with a good way to handle the colorbar, ticks, ticklabels, the axes etc.

The best way forward would be to generate FITS images, based on your HEALPix map (e.g. using hp.cartview(..., return_projected_map=True) or using the reproject package).

You also need to generate the right FITS header for that, astropy would be the right tool for that (how-to manipulate FITS headers).

Once you have that, you can use the excellent WCSAxes framework within astropy, which gives you plenty of well-documented customization options.

Daniel Lenz
  • 3,334
  • 17
  • 36