Hi there,
I’m looking for a way to hide markers on a map based on the ‘Capacity’ value in my pandas Dataframe.
I used an example i found on towardsdatascience to create my markers for each of my 6 categories like so:
def value_select(keyword):
var = df.loc[df['Type'] == project, keyword]
return var
for project in project_categories:
project_data = dict(
type = 'scattermapbox',
lat = value_select('latitude'),
lon = value_select('longitude'),
name = project,
mode = 'markers',
text = 'removed for privacy'
hoverinfo = 'text',
marker = dict(size=size,
sizemode='area',
sizeref=2*max(size)/10,
sizemin=8,
opacity = 0.8
),
)
data.append(project_data)
I can hide the different marker groups just like in the example I found online:
updatemenus= list([ dict( buttons=list([ dict(label = 'All', method = 'update', args = [{'visible': [True, True, True, True, True,]}] ), dict(label = '', method = 'update', args = [{'visible': [True, False, False, False, False]}] ), dict(label = '', method = 'update', args = [{'visible': [False, True, False, False, False]}] ), dict(label = '', method = 'update', args = [{'visible': [False, False, True, False, False]}] ), dict(label = '', method = 'update', args = [{'visible': [False, False, False, True, False]}] ), dict(label = '', method = 'update', args = [{'visible': [False, False, False,False, True]}] ), ]), direction = 'up', x = 0.01, xanchor = 'left', y = 0.01, yanchor = 'bottom', bgcolor = '#000000', bordercolor = '#FFFFFF', font = dict(size=11) ), )]
I have tried using transforms (just got the error of invalid property) and basically anything I could think of, but to no avail. My goal is to use an updatemenus
dropdown with around 4-5 options to hide all markers regardless of category if their ‘Capacity’ value is <1, <2, >15 etc.
Any pointers towards the right direction would be greatly appreciated.
PS: I’m using the latest plotly release with python 3.6 and using offline.plot to generate html files