Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when plotting with vbar on an xaxis that's a datetime axis, how can I set the width of the bars to be "one day"?

Tags:

python

bokeh

This certainly makes the width of the bars wider, but would be better to set them to "1 day" wide:

source = ColumnDataSource(df)
p = figure(x_axis_type="datetime", height=200, ...)
...
c.vbar('dt', top='pct_change', width=100000000, source=source)
like image 832
Chris Withers Avatar asked May 08 '18 16:05

Chris Withers


1 Answers

You can give a timedelta object as the width keyword argument, it will be converted to milliseconds.

import datetime

...

c.vbar('dt', top='pct_change', width=datetime.timedelta(days=1), source=source)

NumberSpec can accept datetime values, unless accept_datetime is set to false.

like image 162
Jacques Gaudin Avatar answered Sep 16 '22 20:09

Jacques Gaudin