【问题标题】:Update in real time fill_color in Bokeh在 Bokeh 中实时更新 fill_color
【发布时间】:2021-09-09 23:21:24
【问题描述】:

我正在尝试从 python 3.8 中散景 2.3.3 中的实时 hex_tile 绘图更新 fill_color。更具体地说,我想更新填充绘图的 linear_cmap 的最大范围。为了更新最大值,我尝试将线性映射器传递给我正在使用的 ColumnDataSource 中的列。我还尝试在图形上使用 .update,并将映射器传递给 fill_color:

def update():
    new_data = bin_generate().to_dict(orient='list')
    source.stream(new_data,rollover = 50)
    maper = linear_cmap('counts', 'Viridis256', 0, max(bin_generate().counts))
    f.hex_tile.fill_color=maper
    #f.hex_tile.fill_color={'transform':maper}

data=bin_generate().to_dict(orient='list')
maper = linear_cmap('counts', 'Viridis256', 0, max(bin_generate().counts))

source = ColumnDataSource(data=data)
f = figure(x_range=(-5,5),y_range=(0,6), toolbar_location=None, tools="hover",
         match_aspect=True, background_fill_color='#440154')

f.hex_tile(q="q", r="r",size=0.09, line_color=None, source=source,  
           fill_color=maper)

curdoc().add_root(f)
curdoc().add_periodic_callback(update,100)

如何更新 cmaper 的最大值?

【问题讨论】:

    标签: python-3.x plot bokeh


    【解决方案1】:

    我没有测试过,但这可以工作:

    首先,给一个名字

    hextile = f.hex_tile(q="q", r="r",size=0.09, line_color=None, source=source,  
               fill_color=maper)
    

    在函数中,添加:

    hextile.glyph.fill_color=maper
    

    你应该先从here查看它

    另外,你应该提供完整的代码和一些数据来检查它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-14
      • 1970-01-01
      • 2023-02-16
      • 1970-01-01
      相关资源
      最近更新 更多