Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import plotly
- import plotly.graph_objs as go
- import plotly.offline as off
- off.init_notebook_mode(connected=True)
- # read in and format data
- df = pd.DataFrame({
- 'bytes': [401385230866526,3864968049982964736,2788251468446959616,2289994746727854592,436912040069473536],
- 'seconds': [1157321220,6973825115020,5781086097984,5112464290449,1016277693729],
- 'labels': list('ABCDE')
- })
- df = pd.melt(df, id_vars=['labels'], value_vars=['bytes', 'seconds'])
- # create traces for each label
- bars = []
- for label in df['labels'].unique():
- sub = df[df['labels'] == label]
- bar = go.Bar(
- x=sub['variable'].tolist(),
- y=sub['value'].tolist(),
- name=label)
- bars.append(bar)
- # make figure
- fig = go.Figure(bars, layout=go.Layout(barmode='stack'))
- # plot
- off.plot(fig)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement