Hi,
I am trying to set different y axis for these graphs. I have accomplished that via secondary_y parameter but with this approach I struggle to add different axis for Bar chart.
Would you please have any idea?
Thanks
from yahooquery import Ticker
import plotly.graph_objects as go
from plotly.subplots import make_subplots
def volumeGraph(ticker, start_date, end_date, value_check):
stock = Ticker(ticker)
average = stock.summary_detail[ticker]['twoHundredDayAverage']
print("new value check {}".format(value_check))
start = start_date
end = end_date
data = []
# TODO https://plotly.com/python/time-series/
df = stock.history(start=start, end=end, interval='1d')
# Create figure with secondary y-axis
fig = make_subplots(specs=[[{"secondary_y": True}]])
moving = go.Scatter(x=[df.index.date.min(), df.index.date.max()], y=[average, average], mode="lines",
name="52w Average")
# Traces
close = go.Scatter(x=df.index.date,
y=df['close'],
name="Close Price",
line=dict(color='#39c1b5'),
)
volume = go.Bar(x=df.index.date,
y=df['volume'],
name="Volume"
)
layout = go.Layout(title=ticker)
data.append(close)
data.append(volume)
print(data)
fig = go.Figure(data=data, layout=layout)
return fig```