title: How create a slider for a custom chorpleth map using plotly in python?
body: <p>I'm create a choropleth map using plotly, geojso and matplotlib. Now i want to add a slider.</p>
  
  <p>i'm using python3 and i can't find a answer for this in the internet.all of them used plotly's default choropleth map. </p>
  
  <pre><code>def get_scatter_colors(sm, df):
      grey = 'rgba(128,128,128,1)'
      return ['rgba' + str(sm.to_rgba(m, bytes = True, alpha = 1)) if not np.isnan(m) else grey for m in df]
  
  
  for age in columns[3:24]:
          age_data = df[age]
          age_data.name = 'province'
          # print(age_data.head())
  
          df_tmp = age_data.copy()
          df_tmp.index = df_tmp.index.map(match_dict)
          df_tmp = df_tmp[~df_tmp.index.duplicated(keep=False)]
  
          df_reindexed = df_tmp.reindex(index = provinces_names)
  
          colormap = 'Blues'
          cmin = df_reindexed.min()
          cmax = df_reindexed.max()
  
          sm = scalarmappable(colormap, cmin, cmax)
          scatter_colors = get_scatter_colors(sm, df_reindexed)
          colorscale = get_colorscale(sm, df_reindexed, cmin, cmax)
          hover_text = get_hover_text(df_reindexed)
  
          scatter_color_list.append(scatter_colors)
  
          tickformat = ""
  
          data = dict(type='scattermapbox',
                      lat=lats,
                      lon=lons,
                      mode='markers',
                      text=hover_text,
                      marker=dict(size=10,
                                  color=scatter_colors,
                                  showscale = True,
                                  cmin = df_reindexed.min(),
                                  cmax = df_reindexed.max(),
                                  colorscale = colorscale,
                                  colorbar = dict(tickformat = tickformat)
                                 ),
                      showlegend=False,
                      hoverinfo='text'
                      )
  
          data_slider.append(data)
  
      layers=([dict(sourcetype = 'geojson',
                    source =sources[k],
                    below="",
                    type = 'line',    # the borders
                    line = dict(width = 1),
                    color = 'black',
                    ) for k in range(n_provinces)
                ] +
  
                # fill_list
              [dict(sourcetype = 'geojson',
                    source =sources[k],
                    below="water",
                    type = 'fill',
                    color = scatter_colors[k],
                    opacity=0.8,
                   ) for k in range(n_provinces)
               ]
              )
  
      steps = []
      for i in range(len(data_slider)):
          step = dict(method='restyle',
                      args=['visible', [False] * len(data_slider)],
                      label='Age {}' .format(i))
          step['args'][1][i] = True
          steps.append(step)
  
      sliders = [dict(active=0, steps=steps)]
  
      layout = dict(title="2016 POPULATION",
                    autosize=False,
                    width=700,
                    height=800,
                    hovermode='closest',
                    # hoverdistance = 30,
  
                    mapbox=dict(accesstoken=MAPBOX_APIKEY,
                                layers=layers,
                                bearing=0,
                                center=dict(
                                          lat=35.715298,
                                          lon=51.404343),
                                pitch=0,
                                zoom=4.9,
                                style = 'light'),
                    sliders=sliders,
                    )
  </code></pre>
  
  <p>when i test this code with data, i want changing color of the map with slides , but the color of map is fixed by the lastest slide color.</p>