I'm using a multi-index data frame to plot a line chart. I can see the correct result when I plot the graph using Matplotlib but the data frame shows the wrong output when plotted using Plotly scatter charts- why?
import pandas as pd
data = pd.DataFrame([
('Q1','Blue',100),
('Q1','Green',300),
('Q2','Blue',200),
('Q2','Green',350),
('Q3','Blue',300),
('Q3','Green',400),
('Q4','Blue',400),
('Q4','Green',450),
],
columns=['quarter', 'company', 'value']
)
data = data.set_index(['quarter', 'company']).value
data.unstack().plot(kind='bar', stacked=True)
The above code plots the right chart. The below code also generate the right result.
fig = go.Figure()
fig.add_trace(go.Scatter(x=sample.index, y=sample['Blue'],
#mode='lines+markers', name='',
#line=dict(color=colors_list[1],width=2,) ,
)
)
but I don't know how to plot both Blue and Green in the scatter plot at the same time?
example:
fig = go.Figure()
fig.add_trace(go.Scatter(x=sample.index, y=sample,
#mode='lines+markers', name='',
#line=dict(color=colors_list[1],width=2,) ,
)
)
Can anyone help how to plot both Blue and Green together?