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 plotly.express).
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 plotly.express 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
df
#Create a Candlestick Price Chart
PriceFigure = go.Figure(
data = [
go.Candlestick(
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 = px.bar(x = df.index, y = df[āVolumeā])
#Update Price Figure layout
PriceFigure.update_layout(
title = āPM Breakoutā,
yaxis_title = āStock Price ($)ā,
xaxis_title = āTimeā,
xaxis_rangeslider_visible = True
)
#Update Volume Figure Layout
VolumeFigure.update_layout(
title = āVolumeā,
yaxis_title = āVolume (M)ā,
xaxis_title = āTimeā
)
#Draw Figures
PriceFigure.show()
VolumeFigure.show()
subplot with shared x axis ?? OR
#link zoom level on both charts ??