2

I am trying to replace the colorbar given by "hp.mollview" with a custom one. In particular I am interested in:

  • Rotating the colorbar by 90 degrees (i.e. replacing the horizontal by a vertical one)
  • Using two labels (left and right of the colorbar)
  • Setting custom ticks
  • Indicating that the range is set (via the "max" parameter) by setting "cmap.set_over".

Minimal amount of code:

import numpy as np
import healpy as hp
m = np.arange(hp.nside2npix(32))
hp.mollview(m)

Any help?

user1834164
  • 377
  • 3
  • 13

1 Answers1

4

I'll expand my comment here:

import numpy as np
import healpy as hp
import matplotlib.pyplot as plt
m = np.arange(hp.nside2npix(32))
hp.mollview(m, cbar=None)

fig = plt.gcf()
ax = plt.gca()
image = ax.get_images()[0]
cmap = fig.colorbar(image, ax=ax)

Then you can customize the colorbar with the function arguments.

Andrea Zonca
  • 8,378
  • 9
  • 42
  • 70