Using a label or axis tick at every x time of day

I’m looking to add a marker to designate a specific time of day. So say for example a plot has an x-axis with datetime between Datetime1 to Datetime2. Looking to add a marker at 3AM and 3 PM. I was not sure if this would be good to do with a custom ticker, although I already have 2 x-axis. The other though I had was to use a label, at those times, but was not sure how best to add a label to every 3AM and 3PM. Any thoughts on how to do this cleanly?


@Mark_Murphy No one has ever asked about this previously and unfortunately I can’t really think of a good immediate solution. What would really be needed is an HoursTicker to complement the current existing DaysTicker, MonthsTicker, and YearsTicker. In terms of getting something on an axis, the only two options I can think of are:

If something outside the axis would suffice (e.g. a marker glyph near the axis but not on it) then there might be options with a CustomJSTransform.

1 Like


Depending on your other requirements, you might be able to co-locate markers or labels on the axes if you’re willing to accept other tradeoffs.

Axes have a fixed_location property, which specifies a position in units of the data. You could conceivably use this to inset the axis in the plot area and leverage knowledge of the placement to overlay markers where you need. (DISCLAIMER: I haven’t tried this; just wanted to call out that specific property in case it inspires a solution.)

Thanks Bryan, always appreciate the support.
I just need some type of indicator every 12 hrs between the dates. It does not have to be on the axis.

@Mark_Murphy I don’t have any exact example at hand. But my idea would be to use a CustomJSTransform to power the x field of the glyph. The transform can be configured with the x_range in its args dict, then in the JS code can identify the desired x positions in between the current range start and end and return a list of those.

twelve_hrs = CustomJSTransform(args=dict(xr=p.x_range), v_func="""
  // JS code to figure out desired x points 
  // between xr.start and xr.end goes here

dummy_source = ColumnDataSource(data=dict(x=[]))

plot.x(x=transform('dummy_x', twelve_hrs), y=0.1, source=dummy_source)