DataRange1d not updating tick-labels

[bokeh 2.3.1]

Hi there,
from what I understood DataRange1d is supposed to automagically fit to the data within its figure.
The data fits nicely, but the ticks do not show the updated values if I change the data.

E.g., the inital data (range 0-5) is displayed correctly, the updated data (range [1e-10])-ish is displayed correctly, but the range is still 0-5 (not 1e-10 to whatever).

I presume there’s some piping missing for the ticks overall as this might be connected to ?

import numpy as np
from bokeh.plotting import figure
from bokeh.layouts import row
from bokeh.models import DataRange1d, Button
from import curdoc

class HistogramFigure:
    def __init__(self, data, bins=20):
        start_vals = data.ravel()
        hhist, hedges = np.histogram(start_vals, range=(start_vals.min(), start_vals.max()), bins=bins)
        hmax = np.max(hhist) * 5
        self.bins = bins

        fig = figure(toolbar_location=None, tools=["pan"],
                    plot_height=200, sizing_mode="stretch_width",
                    y_range=(1e-1, hmax), y_axis_type="log", y_axis_location="right")

        self.h_main = fig.quad(bottom=1, left=hedges[:-1], right=hedges[1:], top=hhist, color="white",line_color="#3A5785")
        fig.background_fill_color = "#fafafa"

        self.fig = fig

    def update(self, data):
        all_vals = np.array(data).ravel()
        hist_all, hedges = np.histogram(all_vals, range=(all_vals.min(), all_vals.max()), bins=self.bins)["top"] = hist_all

big_value_data = 5 * np.random.ranf(2000)
print(big_value_data.min(), big_value_data.max())
hist = HistogramFigure(big_value_data)
def change_hist_data():
    small_value_data = 1e-6 * np.random.ranf(2000)
    print(small_value_data.min(), small_value_data.max())
button = Button(name="Change Hist Data")
curdoc().add_root(row(hist.fig, button))

Sorry about that, I’m a dummy.

I forgot to set “left” and “right” of the histogram data-source, so the interval obviously was not going to change.

1 Like