Plotly: How to style a plotly figure so that it doesn't display gaps for missing dates?

后端 未结 2 2025
半阙折子戏
半阙折子戏 2020-12-18 13:18

I have a plotly graph of the EUR/JPY exchange rate across a few months in 15 minute time intervals, so as a result, there is no data from friday evenings to sunday evenings.

2条回答
  •  庸人自扰
    2020-12-18 14:18

    thanks for the amazing sample! works on daily data but with intraday / 5min data rangebreaks only leave one day on chart

        # build complete timepline 
        dt_all = pd.date_range(start=df.index[0],end=df.index[-1], freq="5T")
        # retrieve the dates that ARE in the original datset
        dt_obs = [d.strftime("%Y-%m-%d %H:%M:%S") for d in pd.to_datetime(df.index, format="%Y-%m-%d %H:%M:%S")]
        # define dates with missing values
        dt_breaks = [d for d in dt_all.strftime("%Y-%m-%d %H:%M:%S").tolist() if not d in dt_obs]
    

提交回复
热议问题