✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Plotly - Paint A Map With Only 3 Colors

I have a problem with Ploty library in Python. When I draw a map with Plotly, it only returns “one-color map” because of its “scale” feature. rep1 But I want a map like act1 . This map has only 3 colors and there are no gradients. I tried to scale values from red to blue or vice versa. But it didn’t make any progress. Is there a way to draw a map with only three colors?

Hi @agenc1,

Plotly computes colors from numeric color arrays using colorscales. It looks like you’ll want to define a custom color scale that use these three colors. There are some examples of custom colorscales at https://plot.ly/python/colorscales/.

Hope that helps!

If you have any followup questions, please include a minimal code example that produces the plot above. Thanks!