Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import plotly
  2. import plotly.graph_objs as go
  3. import plotly.offline as off
  4. off.init_notebook_mode(connected=True)
  5.  
  6. # read in and format data
  7. df = pd.DataFrame({
  8. 'bytes': [401385230866526,3864968049982964736,2788251468446959616,2289994746727854592,436912040069473536],
  9. 'seconds': [1157321220,6973825115020,5781086097984,5112464290449,1016277693729],
  10. 'labels': list('ABCDE')
  11. })
  12. df = pd.melt(df, id_vars=['labels'], value_vars=['bytes', 'seconds'])
  13.  
  14. # create traces for each label
  15. bars = []
  16. for label in df['labels'].unique():
  17. sub = df[df['labels'] == label]
  18. bar = go.Bar(
  19. x=sub['variable'].tolist(),
  20. y=sub['value'].tolist(),
  21. name=label)
  22. bars.append(bar)
  23.  
  24. # make figure
  25. fig = go.Figure(bars, layout=go.Layout(barmode='stack'))
  26.  
  27. # plot
  28. off.plot(fig)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement