简体   繁体   English

悬停image_rgba散景

[英]Hover image_rgba Bokeh

I'd like to be able to hover over a RGBA image using Bokeh. 我希望能够使用Bokeh将鼠标悬停在RGBA图像上。 For this purpose, I'd like to specify a channel as the value when hovering or another data with the same shape. 为此,我想在悬停或其他形状相同的数据时将通道指定为值。 For example, here it follows a minimal example, where I'd like to display a pixel's alpha value on hover, which does not work: 例如,这里遵循一个最小的示例,在此示例中,我想在悬停时显示像素的Alpha值,该方法不起作用:

from __future__ import division

import numpy as np

from bokeh.plotting import figure, show

N = 20
rgba = np.empty((N,N, 4), dtype=np.uint8)
for i in range(N):
    for j in range(N):
        rgba[i, j, 0] = int(i/N*255)
        rgba[i, j, 1] = 158
        rgba[i, j, 2] = int(j/N*255)
        rgba[i, j, 3] = 255

img = np.squeeze(rgba.view(np.uint32))
data = dict(image=[img],
    x=[0],
    y=[0],
    dw=[20],
    dh=[10],
    value=[rgba[:,:,3]])

TOOLTIPS = [
    ("x", "$x"),
    ("y", "$y"),
    ("value", "@value")
]

# must give a vector of images
p = figure(plot_width=400, plot_height=400, x_range=(0, 20), y_range=(0, 10), tools='hover,wheel_zoom', tooltips=TOOLTIPS)
p.image_rgba(source=data, image='image', x='x', y='y', dw='dw', dh='dh')
show(p) 

Is it possible to provide this kind of visualisation with Bokeh? 是否可以使用Bokeh提供这种可视化效果?

While implementing Image hover in Bokeh, I discussed the possibility of supporting ImageRGBA hover as well but we were not entirely clear how hover should behave in that case. 在Bokeh中实现Image hover时,我还讨论了支持ImageRGBA hover的可能性,但是我们还不完全清楚在这种情况下应该如何进行hover。 As of Bokeh 1.0.4, ImageRBGA hover in Bokeh is not yet supported but if you file a GitHub issue, I think that could reopen discussion and get this feature implemented. 从Bokeh 1.0.4开始,尚不支持Bokeh中的ImageRBGA悬停,但是如果您提出GitHub问题,我认为可以重新开始讨论并实现此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM