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?

2
  • you should disable the colorbar in mollview and then add a custom one with Figure.colorbar Commented Mar 28, 2014 at 11:49
  • Can you a minimal amount of code?
    – tacaswell
    Commented Mar 28, 2014 at 12:55

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.