Bokeh graph doesn't plot properly

后端 未结 1 1859
梦毁少年i
梦毁少年i 2021-01-28 06:30

The following code doesn\'t generate a graph:

import pandas
import numpy as np
from bokeh.plotting import figure, show, output_file
from bokeh.io import output_n         


        
相关标签:
1条回答
  • 2021-01-28 07:12

    OK, as far as I can tell, this is what you want (using some project sample data, since you did not provide anything to run your code with):

    from bokeh.plotting import figure, show
    from bokeh.sampledata.commits import data
    
    p = figure(x_axis_type="datetime", y_axis_type="datetime")
    p.circle(x=data.index, y=data.index.time)
    show(p)
    

    The datetime axis type, as the name suggests, treats the timestamps as datetimes. I.e., these are interpreted as hours of the day in the first day of the first year of Epoch. That's why the axis starts and ends with 1/01 and 1/02. You might want to use customize the tick formatter to display just the hours.

    For reference, data looks like this:

    0 讨论(0)
提交回复
热议问题