栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用datetime作为x轴时,如何使bokeh忽略缺少的日期

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用datetime作为x轴时,如何使bokeh忽略缺少的日期

更新:从散景开始,

0.12.6
您可以为轴上的主要刻度标签指定替代。

import pandas as pdfrom bokeh.io import show, output_filefrom bokeh.plotting import figurefrom bokeh.sampledata.stocks import MSFTdf = pd.Dataframe(MSFT)[:50]inc = df.close > df.opendec = df.open > df.closep = figure(plot_width=1000, title="MSFT Candlestick with Custom X-Axis")# map dataframe indices to date strings and use as label overridesp.xaxis.major_label_overrides = {    i: date.strftime('%b %d') for i, date in enumerate(pd.to_datetime(df["date"]))}# use the *indices* for x-axis coordinates, overrides will print better labelsp.segment(df.index, df.high, df.index, df.low, color="black")p.vbar(df.index[inc], 0.5, df.open[inc], df.close[inc], fill_color="#D5E1DD", line_color="black")p.vbar(df.index[dec], 0.5, df.open[dec], df.close[dec], fill_color="#F2583E", line_color="black")output_file("custom_datetime_axis.html", title="custom_datetime_axis.py example")show(p)

如果您有很多日期,则此方法可能会变得笨拙,并且可能需要自定义扩展。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/645165.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号