I have some spatially-distributed data. I'm plotting this with matplotlib.pyplot.hexbin
and would like to change the "background" (i.e. zero-value) colour. An example is shown below - my colour-map of choice is matplotlib.cm.jet
:
How can I change the base colour from blue to white? I have done something similar with masked arrays when using pcolormesh
, but I can't see anyway of doing so in the hexbin
arguments. My instinct would be to edit the colourmap itself, but I've not had much experience with that.
I'm using matplotlib v.0.99.1.1
hexbin(x,y,mincnt=1)
should do the trick. Essentially, you only want to display the hexagons with more than 1 count in them.
from numpy import linspace
from numpy.random import normal
from pylab import hexbin,show
n = 2**6
x = linspace(-1,1,n)
y = normal(0,1,n)
h = hexbin(x,y,gridsize=10,mincnt=0)
gives,
and h = hexbin(x,y,gridsize=10,mincnt=1)
gives,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With