☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

How do i set x axis to value of pandas df?

Community Support
BiggestSmile
BiggestSmile

I’m plotting OHLCV values with bokeh and having hard time figuring out how to set x axis to corresponding “open_time” from panda df.

This is how i plot

p = figure(plot_width=900, plot_height=400)#, x_axis_type='datetime')
    p.segment('bar', 'high', 'bar', 'low', source=src, line_width=1, color='black')  # plot the wicks
    p.vbar('bar', 0.7, 'close', 'open', source=src, line_color='white', fill_color='colors', )  # plot the body

    hover = HoverTool(tooltips=[
        ('date', '@open_time{%F %T}'),
        ('open', '@open{0.0000f}'),
        ('high', '@high{0.0000f}'),
        ('low', '@low{0.0000f}'),
        ('close', '@close{0.0000f}')
    ],
        formatters={'@open_time': 'datetime'})
    p.add_tools(hover)
⌁   Link to post
BiggestSmile
BiggestSmile

Found out that vbars are there, just it’s scale is very small
Changed to 200000 to look like 1 with the default x-axis
I guess it’s due to being default ticker size of ms & 1 of width
Is there any way to account for this without the huge numbers?

⌁   Link to post
Bryan
Bryan

Datetime axes are always denominated in ms since epoch. IIRC you can supply an actual datetime interval object for the width and it be converted automatically. But if you need/want to pass a plain number, it needs to be in the correct units (ms).

⌁   Link to post

End of archived discussion · Replies are disabled