Skip to content

Instantly share code, notes, and snippets.

@emmagrimaldi
Created October 17, 2018 02:06
Show Gist options
  • Select an option

  • Save emmagrimaldi/607c486d3bf7c5271d22e1f88ad3abb2 to your computer and use it in GitHub Desktop.

Select an option

Save emmagrimaldi/607c486d3bf7c5271d22e1f88ad3abb2 to your computer and use it in GitHub Desktop.
updatemenus=list([
# drop-down 1: map styles menu
# buttons containes as many dictionaries as many alternative map styles I want to offer
dict(
buttons=list([
dict(
args=['mapbox.style', 'dark'],
label='Dark',
method='relayout'
),
dict(
args=['mapbox.style', 'light'],
label='Light',
method='relayout'
),
dict(
args=['mapbox.style', 'outdoors'],
label='Outdoors',
method='relayout'
),
dict(
args=['mapbox.style', 'satellite-streets'],
label='Satellite with Streets',
method='relayout'
)
]),
# direction where I want the menu to expand when I click on it
direction = 'up',
# here I specify where I want to place this drop-down on the map
x = 0.75,
xanchor = 'left',
y = 0.05,
yanchor = 'bottom',
# specify font size and colors
bgcolor = '#000000',
bordercolor = '#FFFFFF',
font = dict(size=11)
),
# drop-down 2: select type of storm event to visualize
dict(
# for each button I specify which dictionaries of my data list I want to visualize. Remember I have 7 different
# types of storms but I have 8 options: the first will show all of them, while from the second to the last option, only
# one type at the time will be shown on the map
buttons=list([
dict(label = 'All Storm Events',
method = 'update',
args = [{'visible': [True, True, True, True, True, True, True]}]),
dict(label = 'Thunderstorm Wind',
method = 'update',
args = [{'visible': [True, False, False, False, False, False, False]}]),
dict(label = 'Hail',
method = 'update',
args = [{'visible': [False, True, False, False, False, False, False]}]),
dict(label = 'Tornado',
method = 'update',
args = [{'visible': [False, False, True, False, False, False, False]}]),
dict(label = 'Marine Thunderstorm Wind',
method = 'update',
args = [{'visible': [False, False, False, True, False, False, False]}]),
dict(label = 'Marine High Wind',
method = 'update',
args = [{'visible': [False, False, False, False, True, False, False]}]),
dict(label = 'Marine Strong Wind',
method = 'update',
args = [{'visible': [False, False, False, False, False, True, False]}]),
dict(label = 'Flash Flood',
method = 'update',
args = [{'visible': [False, False, False, False, False, False, True]}])
]),
# direction where the drop-down expands when opened
direction = 'down',
# positional arguments
x = 0.01,
xanchor = 'left',
y = 0.99,
yanchor = 'bottom',
# fonts and border
bgcolor = '#000000',
bordercolor = '#FFFFFF',
font = dict(size=11)
)
])
# assign the list of dictionaries to the layout dictionary
layout['updatemenus'] = updatemenus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment