Hi there,
I am newbie to plotly, with few days of experience.
I am trying to produce 2x1 subplots, with mixed type (OHLC and Bar). I have been kept reading the manual (Mixed subplots in Python) but could not figure out what is wrong with my code.
Whenever i add the OHLC data, it gives
ValueError:
Invalid element(s) received for the βdataβ property of
Invalid elements include:β¦
Below is my code that i have been stuck for 2 days
# import plotly
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import pandas as pd
# creating subplot, 2x1, shared x-axis
fig = make_subplots(rows=2, cols=1,
shared_xaxes=True,
vertical_spacing=0.22,
specs= [ [{"type": "candlestick"}],
[{"type": "bar"}]
]
)
# add data for subplot, price OHLC chart
df_price = pd.read_csv('Resamp_Daily_OHLC.csv')
trace1 = go.Figure(data=go.Ohlc(x=df_price['Date'],
open=df_price['open'],
high=df_price['high'],
low=df_price['low'],
close=df_price['close']))
# add data for subplot, Volume
df_volume = pd.read_csv('Daily_BS_Total.csv')
trace2 = go.Bar(x=df_volume['Date'], y=df_volume['Trade Vol'])
# plotting
fig.add_trace(go.Bar(x=df_volume['Date'], y=df_volume['Trade Vol']),
row=1,col=1
)
fig.add_trace(go.Figure(data=go.Candlestick(x=df_price['Date'],
open=df_price['open'],
high=df_price['high'],
low=df_price['low'],
close=df_price['close'])),
row=2,col=1
)
fig.update(layout_xaxis_rangeslider_visible=True)
fig.update_layout(height=600, width=1000,
title_text='Stacked Subplots with Shared X-axes')
fig.show()
I just would like to inform that if I plot the OHLC chart alone, there is no Value Error.
Thank you in advance. Regards