# stacked bar plot with plotly
import plotly.graph_objs as go
import plotly.offline as pyo
import pandas as pd
d={
'company':['x1','x2','x3','x4','x5'],
'score1':[12,14,13,10,15],
'score2':[23,18,18,17,24],
'score3':[10,12,12,11,15],
'score4':[20,20,20,20,20]
}
s=pd.DataFrame(d)
s.set_index('company',inplace=True)
trace0=go.Bar(x=s.index,y=s['score1'],marker={'color':'rgb(49,130,189)'},width =.4)
trace1=go.Bar(x=s.index,y=s['score2'],marker={'color':'rgb(204,204,204)'},width =.4)
trace2=go.Bar(x=s.index,y=s['score3'],width =.4)
trace3=go.Bar(x=s.index,y=s['score4'],width =.4)
data=[trace0,trace1,trace2,trace3]
layout=go.Layout(barmode='stack')
figure=go.Figure(data,layout)
pyo.plot(figure)