Search code examples
pythontime-seriesbokeh

Slope on bokeh time series plot


What's the internal representation of the datetime in bokeh time series plot, for example, in https://docs.bokeh.org/en/latest/docs/gallery/candlestick.html this candlestick charts, how to plot a slope with 45 degree angle ? (when calculating the slop / gradient, should I use seconds based epoch on datetime axis or microseconds ? nano ?)


Solution

  • Looks bokeh is using ms internally for time series plot. so,

    g = 1 / (24 * 3600 * 1e3)
    Slope(gradient=g, y_intercept=66 - g * (df['date'][0].timestamp() * 1e3)
    

    should plot the 45 degree slope line.