Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # NOTE: This code goes in between 'START' and 'END' below
- traces = []
- for data in datas:
- traces.append(go.Box(
- x=data.index,
- y=data.values,
- showlegend=False
- ))
- import plotly.offline as py
- import plotly.graph_objs as go
- from plotly.offline import init_notebook_mode, iplot, plot
- from plotly import tools
- init_notebook_mode(connected=True)
- ### Create individual figures
- # START
- traces = []
- for data in datas:
- fig = tools.make_subplots(rows=1, cols=2)
- trace1 = go.Box(
- x=data.head(10).index,
- y=data.head(10).values,
- showlegend=False
- )
- trace2 = go.Box(
- x=data.tail(10).index,
- y=data.tail(10).values,
- showlegend=False
- )
- fig.append_trace(trace1, 1, 1)
- fig.append_trace(trace2, 1, 2)
- traces.append(fig)
- # END
- ### Create buttons for drop down menu
- buttons = []
- for i, label in enumerate(labels):
- visibility = [i==j for j in range(len(labels))]
- button = dict(
- label = label,
- method = 'update',
- args = [{'visible': visibility},
- {'title': label}])
- buttons.append(button)
- updatemenus = list([
- dict(active=-1,
- x=-0.15,
- buttons=buttons
- )
- ])
- layout = dict(title='Title',
- showlegend=False,
- updatemenus=updatemenus)
- fig = dict(data=traces, layout=layout)
- iplot(fig, filename='dropdown')
Add Comment
Please, Sign In to add comment