如何从补丁图中删除未添加的日期时间

时间:2018-08-09 13:15:10

标签: python charts bokeh

我使用bokeh补丁图来获取我的能量数据。它成功工作了默认时间序列。但是,如果我选择了不同的两个日期,那么它将合并两个日期范围块

示例: 日期范围:29/07/2018 - 31/07/2018 with hours

Successfull working example of result is here

日期:30/07/2018 and 06/08/2018 with hours

Wrongly working example of result is here

所以我尝试了this帖子,但它没有任何改变。

和代码块:

df = generateRtpDataFrame(data_list,frekans)
df=df.round(2)
def stacked(df):
    df=df[df.columns[::-1]]
    df_top = df.cumsum(axis=1)     
    df_bottom = df_top.shift(axis=1).fillna({'total': 0})[::-1]        
    df_stack = pd.concat([df_bottom, df_top], ignore_index=False)
    df_stack=df_stack.drop("total", axis=1)
    return df_stack
areas = stacked(df)
colors = d3['Category20b'][areas.shape[1]]

x2 = np.hstack((df.index[::-1], df.index))   
msg = "Example Plot"     
caption = Title(text=msg, align='left', text_font_size='10pt')
tooltips=[
    ("index", "$index"),          
]
p = figure(sizing_mode = 'scale_width',tooltips=tooltips,x_axis_type='datetime')           
p.add_layout(caption, 'above')    
p.grid.minor_grid_line_color = '#eeeeee'
p.xaxis.formatter=DatetimeTickFormatter(
    minutes=["%M"],
    hours=["%H:%M"],
    days=["%d/%m/%Y"],
    months=["%m/%Y"],
    years=["%Y"],
)

p.xaxis.major_label_overrides = {
    i: date.strftime('%Y-%m-%d %H:%M') for i, date in enumerate(pd.to_datetime(df.index))
}        
p.patches(xs=[x2]*areas.shape[1],ys= [areas[c].values for c in areas], color=colors, alpha=0.8,line_color=None)

0 个答案:

没有答案