How to remove weekend datetime gaps from x-axis of a financial chart?

前端 未结 5 951
[愿得一人]
[愿得一人] 2021-01-06 16:31

I have a use case where I pull and plot Forex data in the form of ask and bid on the graph and this is based on minute, hour or day candlesti

5条回答
  •  被撕碎了的回忆
    2021-01-06 17:05

    Using category as the xaxis type worked for me quite nicely (notice the go.Layout object):

        import plotly.graph_objects as go
    
        layout = go.Layout(
            xaxis=dict(
                type='category',
            )
        )
    
        fig = go.Figure(data=[go.Candlestick(x=self.price_df.index.to_series(),
                                             open=self.price_df[e.OHLCV.OPEN.value],
                                             high=self.price_df[e.OHLCV.HIGH.value],
                                             low=self.price_df[e.OHLCV.LOW.value],
                                             close=self.price_df[e.OHLCV.CLOSE.value])],
                        layout=layout)
    
        fig.show()
    

提交回复
热议问题