散景无法更改日期时间轴格式

Bokeh cannot change datetime axis format

我正在遵循不同的代码来了解如何在 x 轴上显示不同的日期时间格式,但出于某种原因,无论我输入什么,轴始终采用 mmmyy 格式,如 Jan17进入 DatetimeTickFormatter。如何更改格式,例如 Jan 15, 2017?

    p=figure(plot_width=800,plot_height=500)
    p.line(x="ENTRYDATE",y="Transactions",color='LightSlateGrey', source=sourceDay)
    p.xaxis.major_label_orientation=1.5
    p.xaxis.formatter=DatetimeTickFormatter(days=["%a\n%d %b"])

ColumnDataSource 的形式为:

ENTRYDATE | Transactions
2017-01-15  29
2017-01-20  30
..
2018-01-03  1

其中 ENTRYDATE 是一个 datetime 对象。提前致谢。

我无法重现您的问题。对我来说,以下基于您的代码的示例有效:

    from bokeh.plotting import figure
    from bokeh.models.sources import ColumnDataSource
    from bokeh.models.formatters import DatetimeTickFormatter
    import bokeh.io as bkio
    import datetime as dt

    date1 = dt.datetime(2017, 1, 15)
    date2 = dt.datetime(2017, 1, 20)

    sourceDay = ColumnDataSource(data=dict(ENTRYDATE=[date1, date2], Transactions = [1, 2]))

    p=figure(plot_width=800,plot_height=500)
    p.line(x="ENTRYDATE",y="Transactions",color='LightSlateGrey', source=sourceDay)
    p.xaxis.major_label_orientation=1.5
    p.xaxis.formatter=DatetimeTickFormatter(days=["%b %d, %Y"])

    bkio.show(p)

您确定数据源 ENTRYDATE-column 中的 datetime-object 吗?