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

Candlestick and volume bar charts are seperate! Can I combine them?

Hello Fam, Python Noob here…

Finally i was able to draw a candlestick Price chart (using plotly.graph_objects) and a Volume Bar Chart (using

Can I plot the charts to be together in one figure? If yes, how? I found this picture online, but i could not replicate it.

If no, how can I link both charts x-axes such that when I zoom on one, the other plots will update?

#import the libraries
import plotly.graph_objects as go
import as px
import pandas as pd

#Load the stock data
df = pd.read_csv(‘20180507-table_blnk.csv’)
#Set the index
df = df.set_index(pd.DatetimeIndex(df[‘Time’].values))
#Show the data

#Create a Candlestick Price Chart
PriceFigure = go.Figure(
data = [
x = df.index,
low = df[‘Low’],
high = df[‘High’],
close = df[‘Close’],
open = df[‘Open’],
increasing_line_color = ‘green’,
decreasing_line_color = ‘red’
#Create a Volume Bar Chart
VolumeFigure = = df.index, y = df[‘Volume’])

#Update Price Figure layout
title = ‘PM Breakout’,
yaxis_title = ‘Stock Price ($)’,
xaxis_title = ‘Time’,
xaxis_rangeslider_visible = True

#Update Volume Figure Layout
title = ‘Volume’,
yaxis_title = ‘Volume (M)’,
xaxis_title = ‘Time’

#Draw Figures

subplot with shared x axis ?? OR

#link zoom level on both charts ??