Black Lives Matter. Please consider donating to Black Girls Code today.

Plot.ly map loads all traces ColorBars on initial open

I am learning plot.ly, and am having a bit of trouble with colorbars in a map with multiple traces (that are being used with a slider). When the map first loads/is opened, all of the colorbars appear at once, stacked on each other. When I slide the slider, the problem remedies itself. Is there a way to maybe initialize the plot differently? The plot and my python code are linked below. Sorry for how non-pythonic most of the code is, I was just trying to see if I could make it work.

https://plot.ly/~benjamin.spargo/25/.embed https://gist.github.com/benspargo89/0bd3783437f99ff650ec2424a6287ec7
*Python code does not include my mapbox token

Thanks, Ben

@ben1989 To fix the colorbar overlay, insert:

  1. showlegend=False in Scattermapbox()

  2. showscale=False

in the data definition, after the line:

color = df['Percent Economically Disadvantaged']

  1. Remove redefinition of colorbar in data[-1]['marker'].update(), and reduce the for loop to this block:
for tick in ticks:
    data.append(data[0].copy())
    data[-1]['marker'].update(showscale=True) 
    data[-1]['text'] = df['School Name'] + "<br>"  + str(tick) + ': ' + 
                              (df[tick].fillna(value=0)*100).astype(dtype='int').astype(dtype='str')

With these changes it works as you expected.

Thank you very much for taking the time to help. I have not had a chance to edit/test yet, but will do tonight.

Thanks!
Ben