Not able to change the marker color based on the column value

Hi @sarahekim53,

The marker_color must be a list of numerical values to be mapped to a colorscale colors. Your code passed a list of strings to the marker_color, not a numerical list.

Hence, you should proceed as follows:

u_states = np.unique(address['state'].values)  #set the array of unique states in your column, address['state']
d = dict(zip(u_states, np.arange(len(u_states))) # a dict that associates a numerical value to each state

Now you can set:

marker_color = [d[s] for s in address['state']]

and so each state will be mapped to a different color on the colorscale (if you did not set any colorscale, Plotly will use the default one: β€˜Plasma’).

1 Like