Plot Stock candlestick subplot chart with bar charts (value area) stacked on it

I am trying to plot a candlestick chart with value area bar chart stacked on it.

Example (something like this),
image

So far, I am able to get output like below

In my plot, I have shared Y-axis and separated X-axis. I am not sure how I can achieve that. I played with axes for some time, but no success. How can I make my plot look like above example? Below is the code for plotting the chart -

NOTE: data_2 is being plotted on (row=1,col=1) and data_1 is being plotted on (row=1, col=2)

from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(rows=1, cols=2, shared_yaxes=True, horizontal_spacing = 0)

fig.update_layout(
    xaxis = {'anchor': 'y', 'overlaying': 'x', 'side': 'bottom'},
    xaxis2 = {'anchor': 'y', 'overlaying': 'x2', 'side': 'bottom'},
)

# Candlestick (t-x)
dateStr = chart_data_2.index.strftime("%d-%m-%Y %H:%M:%S")
fig.add_trace(
        go.Candlestick(
            x       = dateStr,
            open    = chart_data_2['open'],
            high    = chart_data_2['high'],
            low     = chart_data_2['low'],
            close   = chart_data_2['close'],
        ),
        row=1, col=1
    )

# Volume Profile
fig.add_trace(
        go.Bar(
            x    = volume_profile_2.values, 
            y    = volume_profile_2.index,
            orientation  = 'h',
            marker_color = ['blue']*len(volume_profile_2),
            opacity      = 0.25
        ),
        row=1, col=1
    )

# POC Line
fig.add_hline(
    y = poc_price_2,
    annotation_text = "POC", 
    annotation_position = "bottom right",
    line_width=1, line_color="red",
    row=1, col=1
)

# VAH Line
fig.add_hline(
    y = VAH_2+0.5,
    annotation_text = "VAH", 
    annotation_position = "top right",
    line_width=2, line_dash="dash", line_color="goldenrod",
    row=1, col=1
)

# VAL Line
fig.add_hline(
    y = VAL_2-0.5,
    annotation_text = "VAL", 
    annotation_position = "bottom right",
    line_width=2, line_dash="dash", line_color="goldenrod",
    row=1, col=1
)


# ───────────────────────────────────────────────────────────────────────────

# Candlestick (t)
dateStr = chart_data_1.index.strftime("%d-%m-%Y %H:%M:%S")
fig.add_trace(
        go.Candlestick(
            x       = dateStr,
            open    = chart_data_1['open'],
            high    = chart_data_1['high'],
            low     = chart_data_1['low'],
            close   = chart_data_1['close'],
            yaxis   = "y2"

        ),
        row=1, col=2
    )


# Volume Profile
fig.add_trace(
        go.Bar(
            x    = volume_profile_1.values, 
            y    = volume_profile_1.index,
            orientation  = 'h',
            marker_color = ['blue']*len(volume_profile_1),
            opacity      = 0.25
        ),
        row=1, col=2
    )

# POC Line
fig.add_hline(
    y = poc_price_1,
    annotation_text = "POC", 
    annotation_position = "bottom right",
    line_width=1, line_color="red",
    row=1, col=2
)

# VAH Line
fig.add_hline(
    y = VAH_1+0.5,
    annotation_text = "VAH", 
    annotation_position = "top right",
    line_width=2, line_dash="dash", line_color="goldenrod",
    row=1, col=2
)

# VAL Line
fig.add_hline(
    y = VAL_1-0.5,
    annotation_text = "VAL", 
    annotation_position = "bottom right",
    line_width=2, line_dash="dash", line_color="goldenrod",
    row=1, col=2
)


fig.update_layout(
    height=600, title_text="Side By Side Subplots",
    xaxis = dict(rangeslider = dict(visible = False)),
    xaxis2 = dict(rangeslider = dict(visible = False))
)


fig.show()

Thanks :slight_smile:

Hi,

I hope u find this useful:

Advanced Tips for Candlestick Plots in Python | by Lucasjamar | Medium

Raindrop Charts in Python in 5 easy steps | Medium

Disclaimer: im the author