I am creating a bar plot that shows relative contributions on a per row basis, such as this:
import pandas as pd
import plotly.express as px
d = pd.DataFrame({'a': [3,4,7], 'b': [5,4,1]})
fig = px.bar(d, x=d.index, y=['a','b'])
fig.show()
When I try to put this into a subplot by adding the plotly express traces, the bars are no longer stacked:
import pandas as pd
import plotly.express as px
from plotly.subplots import make_subplots
d = pd.DataFrame({'a': [3,4,7], 'b': [5,4,1]})
fig = px.bar(d, x=d.index, y=['a','b'])
fig2 = make_subplots(2,2)
fig2.add_traces(list(fig.select_traces()), rows=1, cols=1)
fig2.show()
Any suggestions on how to reproduce the plotly express behavior within the subplot would be appreciated.
Thank you - Marie