
Hello! I have realized I am far too dumb to be able to use DateTimeTicker…
I would like to make it so that my plot has always 10 ticks with their respective DateTime visible. The number 10 is arbitrary. I just want a more dense ticker than the default one.
Here is an example code with me specifying the ticker as suggested by the source code of the DateTimeTicker.
from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource, Plot, AdaptiveTicker, DaysTicker
import numpy as np
import pandas as pd
ONE_MILLI = 1.0
ONE_SECOND = 1000.0
ONE_MINUTE = 60.0 * ONE_SECOND
ONE_HOUR = 60 * ONE_MINUTE
TICKERS = [
AdaptiveTicker(
mantissas=[1],
base=10,
min_interval=ONE_HOUR,
max_interval=2*ONE_HOUR,
num_minor_ticks=0
)
]
p = figure(width=300, height=300, tools="pan,reset,save,box_zoom,zoom_in,zoom_out", x_axis_type="datetime", sizing_mode="stretch_both")
p.xaxis.ticker.tickers = TICKERS
POINTS_COUNT = 100000
source = ColumnDataSource(data={"x": pd.date_range(start="2022-01-01", end="2022-01-03", periods=POINTS_COUNT), "y": np.random.rand(1, POINTS_COUNT)[0]})
doc = curdoc()
p.scatter(source=source)
doc.add_root(p)
This works well for the view we get on startup but the ticks get sparse as we zoom in. I try adding another AdaptiveTicker and that’s where the trouble starts. The behaviour of zoom seems to be changing almost randomly. How does the CompositeTicker decide which AdaptiveTicker to use? It’s really hard for me to deduce that from user’s perspective.
On the other hand, maybe there is a simpler method of making sure we get two or more times ticks visible everytime?

