Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Widening spaces between candlesticks

Hello,

I was looking for a way to adjust spaces between candlesticks.

I’ve tried searching a lot but there was no option like ‘bargap’ in bar chart.

What I want to do is make candlestick chart sparse so that,

eventually I can put some trade records with triangles on the left side of corresponding candle.

But for now it is quite overlapping each other no matter how I put markers in-between candles by adjusting time.

Is there a clear way or any work-around?

Thank you.

Below is my code with Plotly v4.14.1

import plotly.graph_objects as go

# Candlestick chart
candle = go.Candlestick(
        x=df.index,
        open=df['Open'],
        high=df['High'],
        low=df['Low'],
        close=df['Close'],

        increasing=go.candlestick.Increasing(
            line=dict(width=1),
            fillcolor='red',
            line_color='red'
        ),
        decreasing=go.candlestick.Decreasing(
            line=dict(width=1),
            fillcolor='blue', 
            line_color='blue'
        )
)

# Buy, Sell markers
markers = list()
for executions in [long, short]:
        markers.append(
            go.Scatter(
                mode='markers', 
                x=executions['time'], 
                y=executions['price'], 
                marker_symbol=8,  # triangle
                marker_line_width=0.5, 
                marker_size=6,
            )
        )

# Draw
fig = go.Figure(data=[candle, *markers])
fig.show()