Bokeh: `alpha` silently not working on `image`

Created on 20 Jun 2016  路  3Comments  路  Source: bokeh/bokeh

I'm running the following piece of bokeh code:

import numpy as np
from bokeh.plotting import figure, show, output_file
from bokeh.tile_providers import STAMEN_TERRAIN

bbox = [-10910125.412422614,
        3520337.5607719547,
        -10861114.121738775,
        3567832.0546971313]

N = 10
x = np.linspace(bbox[0], bbox[2], N)
y = np.linspace(bbox[1], bbox[3], N)
xx, yy = np.meshgrid(x, y)
d = np.sin(xx)*np.cos(yy)

p = figure(x_range=(bbox[0], bbox[2]), y_range=(bbox[1], bbox[3]))
p.add_tile(STAMEN_TERRAIN)

p.image(image=[d], x=bbox[0], y=bbox[1], \
        dw=bbox[2]-bbox[0], dh=bbox[3]-bbox[1], \
        alpha=0.5, palette='Blues9')

output_file('image.html', title='test')
show(p)

which, when you open the html file created, looks like:

screen shot 2016-06-20 at 16 44 21

As can be seen, even though I have included alpha=0.5, the overlaid image is completely opaque, not allowing to see through it. According to the bokeh documentation, alpha is allowed, but it does not seem to make any effect.

duplicate discussion

Most helpful comment

Oh I see. The issue is that the alpha and color keywords are conveniences to set line_alpha/fill_alpha and line_color/fill_color more easily. That is the useful thing for almost eveyr other glyph, but it does not do anything useful for image. Options:

  • try to make it meaning for image as well
  • explicitly remove it from image and other glyphs it does not apply to

Either way it probably makes sense to add a global_alpha property to Image since it does not currently have one.

All 3 comments

Oh I see. The issue is that the alpha and color keywords are conveniences to set line_alpha/fill_alpha and line_color/fill_color more easily. That is the useful thing for almost eveyr other glyph, but it does not do anything useful for image. Options:

  • try to make it meaning for image as well
  • explicitly remove it from image and other glyphs it does not apply to

Either way it probably makes sense to add a global_alpha property to Image since it does not currently have one.

Classifying as bug since docs are misleading, at a minimum.

this was duped by #7474 (not noticed) and that issue has been completed and closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samhile picture samhile  路  3Comments

cyrusmaher picture cyrusmaher  路  3Comments

taiwotman picture taiwotman  路  3Comments

sggaffney picture sggaffney  路  3Comments

agoodm picture agoodm  路  4Comments