5

I'm trying to use others colormaps on healpy.mollview I succeded with this code

from healpy import mollview
from pylab import arange, show, cm
m = arange(768)
mollview(m, cmap=cm.bwr)
show()

but I get an unexpected blue background and there is no way I can set it to white

tmdavison
  • 64,360
  • 12
  • 187
  • 165

3 Answers3

7

healpy seems to make a modification to its default colormap to change what happens when the color is out of range. So, we need to do the same before we give cm.bwr to healpy. We can do this with cmap.set_under('w') to set the color to white.

This seems like a bug in healpy to me, since this will affect most colormaps you try to use.

from healpy import mollview,cartview
from pylab import arange, show, cm

cmap = cm.bwr
cmap.set_under('w')

m = arange(768)
mollview(m, cmap=cmap)
show()

enter image description here

To fully mimic what healpy does to its default colormap (it uses jet), we need to set the over, under and bad values. Here's the relevant function from the healpy github.

cmap=cm.bwr
cmap.set_over(cmap(1.0))
cmap.set_under('w')
cmap.set_bad('gray')
tmdavison
  • 64,360
  • 12
  • 187
  • 165
0

What you see is not an unexpected background colour. The colormap you use makes the lowest value in your plot appear blue. Since the stuff around you circular thing seems to be zero, this appears blue in the figure. Try using a colormap that is white at zero.

thomas
  • 1,773
  • 10
  • 14
  • the area around the projection is not zero. If you hover the mouse there is just shows an empty list `[]` where the value would normally be. You can fix this by changing the `set_under` value, rather than restricting yourself to a colormap which starts at white. See my answer for an example. – tmdavison Dec 01 '15 at 16:18
0

Update ~/anaconda3/lib/python3.7/site-packages/healpy/projaxes.py:

Replace all newcm.set_bad("gray") to newcm.set_bad((1, 1, 1, 1)).

In the example below, I have updated it to newcm.set_bad((0, 0, 0, .9)) to highlight how it works.

@tmdavison's answer doesn't work for customized normalization function. But the edit above would.

from healpy import mollview
from pylab import arange, show, cm, Normalize
m = arange(768)

mollview(m, cmap=cm.bwr, norm=Normalize(vmin=0, vmax=768))
show()

enter image description here

Miladiouss
  • 4,270
  • 1
  • 27
  • 34