Guest User

Untitled

a guest
May 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. # NOTE: This code goes in between 'START' and 'END' below
  2. traces = []
  3. for data in datas:
  4. traces.append(go.Box(
  5. x=data.index,
  6. y=data.values,
  7. showlegend=False
  8. ))
  9.  
  10. import plotly.offline as py
  11. import plotly.graph_objs as go
  12. from plotly.offline import init_notebook_mode, iplot, plot
  13. from plotly import tools
  14. init_notebook_mode(connected=True)
  15.  
  16. ### Create individual figures
  17. # START
  18. traces = []
  19. for data in datas:
  20. fig = tools.make_subplots(rows=1, cols=2)
  21.  
  22. trace1 = go.Box(
  23. x=data.head(10).index,
  24. y=data.head(10).values,
  25. showlegend=False
  26. )
  27. trace2 = go.Box(
  28. x=data.tail(10).index,
  29. y=data.tail(10).values,
  30. showlegend=False
  31. )
  32. fig.append_trace(trace1, 1, 1)
  33. fig.append_trace(trace2, 1, 2)
  34. traces.append(fig)
  35. # END
  36.  
  37. ### Create buttons for drop down menu
  38. buttons = []
  39. for i, label in enumerate(labels):
  40. visibility = [i==j for j in range(len(labels))]
  41. button = dict(
  42. label = label,
  43. method = 'update',
  44. args = [{'visible': visibility},
  45. {'title': label}])
  46. buttons.append(button)
  47.  
  48. updatemenus = list([
  49. dict(active=-1,
  50. x=-0.15,
  51. buttons=buttons
  52. )
  53. ])
  54.  
  55. layout = dict(title='Title',
  56. showlegend=False,
  57. updatemenus=updatemenus)
  58.  
  59. fig = dict(data=traces, layout=layout)
  60.  
  61. iplot(fig, filename='dropdown')
Add Comment
Please, Sign In to add comment