i know how to use a ColumnDataSource to change q
and r
of hex_tile
, but i’d like to change size
as well. is it possible?
so specifically, consider this example, which i copy here and modify to use a ColumnDataSource:
import numpy as np
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.transform import linear_cmap
from bokeh.util.hex import hexbin
n = 50000
x = np.random.standard_normal(n)
y = np.random.standard_normal(n)
bins = hexbin(x, y, 0.1)
cds = ColumnDataSource(bins)
p = figure(title="Manual hex bin for 50000 points", tools="wheel_zoom,pan,reset",
match_aspect=True, background_fill_color='#440154')
p.grid.visible = False
p.hex_tile(q="q", r="r", size=0.1, line_color=None, source=cds,
fill_color=linear_cmap('counts', 'Viridis256', 0, max(bins.counts)))
output_file("hex_tile.html")
show(p)
how do i subsequently change hex_tile
's size
to match a new hexbin()
with a different size
argument:
bins2 = hexbin(x, y, 0.2) ### same data (x,y), but new size=0.2
cds.data.update(q=bins2['q'], r=bins2['r'], counts=bins2['counts'], index=range(len(bins2['counts'])))
the plot is updated, but the axes are scaled by 2. but since it’s the same data, i want the axes to be the same. possible? thanks.