python - Plot showing up black in Bokeh -


i trying plot radar data in bokeh hdf5 file. i've stored data 2d array 1800*3600. when try plot data using p.image shows black splotches i'm assuming data greater 0, doesn't conform palette i've specified. i'm not sure why occurring.

f = h5py.file(fname, 'r') lat = f['grid']['lat'] lon = f['grid']['lon'] precip = f['grid']['precipitationcal'] precip = np.transpose(precip)  d = np.empty((1800,3600)) (x,y), value in np.ndenumerate(precip):     if value <= 0:         d[x,y]=np.nan     else:         d[x,y]=value   output_file("testimage.html", title="image.py example") p = figure(x_range = [0, 3600], y_range=[0, 1800]) p.image(image=[d],x=[0],y=[0],dw=[3600], dh=[1800], pallete="spectral-256") show(p) 

enter image description here

two things:

first, argument pass p.image spelled "palette" not "pallete". default palette grey9, give colormap have.

second (and docs sort of unclear on this), palette argument accepts list containing colormap hex values. can either arbitrary list:

palette = ["#8c9494", "#8398a2", "#7c9baa"]  p.image(image=[d],x=[0],y=[0],dw=[360], dh=[180], palette=palette) 

or standard palette bokeh

from bokeh.palettes import spectral6 p.image(image=[d],x=[0],y=[0],dw=[360], dh=[180], palette=spectral6) 

note:

print(spectral6) > ['#3288bd', '#99d594', '#e6f598', '#fee08b', '#fc8d59', '#d53e4f'] 

source: http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -