How to remove these empty spaces in candle stick?

import plotly.express as px
import plotly.graph_objects as go

trace = {
    'x': dataset.date + " " + dataset.time,
    'open': dataset.open,
    'close': dataset.close,
    'high': dataset.high,
    'low': dataset.low,
    'type': 'candlestick',
    'name': 'EURUSD'
}

layout = go.Layout({
    'title': {
        'text': 'EUR / USD',
        'font': {
            'size': 15
        }
    }
})

fig = go.Figure(data = [trace], layout=layout)

fig.show()

Hello @aadarsh and welcome to the plotly community !

Have you checked out this example from the docs for hiding weekends and non business hours in timeseries visualizations.
Go to the Hiding Weekends and holidays sections on this page.

Yep, Encountering this issue!

def plyplot(dataset, name = ""):
  
  trace = {
      'x': dataset.date + " " + dataset.time,
      'open': dataset.open,
      'close': dataset.close,
      'high': dataset.high,
      'low': dataset.low,
      'type': 'candlestick',
      'name': name
  }

  layout = go.Layout({
      'title': {
          'text': name,
          'font': {
              'size': 15
          }
      }
  })

  fig = go.Figure(data = [trace], layout=layout)

  fig.update_xaxes(
    rangebreaks=[
        dict(bounds=["sun", "sat"], pattern="day"),
    ]
  )

  fig.show()

Hi @atharvakatre

I have tried to hide the gaps in every possible way with xaxes type=β€œdate”, and I just could not.

The link you have provided may perhaps work for daily charts, but what about H4 charts, M15 charts?

The closest I got to my goal of removing the gaps was with

rangebreaks=[dict(enabled=True, pattern="day of week")]

However, this does not work well for financial candlestick charts in different timeframes (H1, H4, M15, etc ). There are still [smaller] gaps, and some candlesticks are dropped or changed.

The only thing that seems to work is to forget about the type=β€œdate”, change my dataframe so that the timestamps are strings and then trick plotly to use string type in the xaxes.

That feels like a defeat.