def create_layout_button(df, column):
first, latest = df.index.values[0], df.index.values[-1]
return dict(label = column,
args = [{'visible': df.columns.isin([column]),
'xaxis.range': [first, latest],
def multi_plot(df, title, addAll = True):
first, latest = df.index.values[0], df.index.values[-1]
for column in df.columns.to_list():
button_all = dict(label = 'All',
args = [{'visible': df.columns.isin(df.columns),
'xaxis.range': [first, latest],
# Need "World" to be the default choice if "All" is not shown
button_world = create_layout_button(df, "World")
"buttons": ([button_all] * addAll) + [button_world] + [create_layout_button(df, column) for column in df.columns if column != "World"],
# Update remaining layout properties