gpt4 book ai didi

python - 在作为日期时间轴的 xaxis 上使用 vbar 进行绘图时,如何将条形的宽度设置为 "one day"?

转载 作者:太空宇宙 更新时间:2023-11-03 14:45:04 25 4
gpt4 key购买 nike

这肯定会使条形宽度变宽,但最好将它们设置为“1 天”宽:

source = ColumnDataSource(df)
p = figure(x_axis_type="datetime", height=200, ...)
...
c.vbar('dt', top='pct_change', width=100000000, source=source)

最佳答案

你可以给一个 timedelta 对象作为 width 关键字参数,它会被转换为毫秒。

import datetime

...

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

NumberSpec可以接受 datetime 值,除非 accept_datetime 设置为 false

关于python - 在作为日期时间轴的 xaxis 上使用 vbar 进行绘图时,如何将条形的宽度设置为 "one day"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50237911/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com