1
votes

I have a choropleth map of the United States, but the border lines separating each state is white against a white background. How do I customize this map to show a black border line instead?

USA Map

Here are my codes:

import chart_studio.plotly as py
import plotly.graph_objects as go
from plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot
init_notebook_mode(connected=True)

data = dict(type = 'choropleth',
            locations = ['AZ','CA','NY'],
            locationmode = 'USA-states',
            colorscale = 'Jet',
            text = ['Arizon','California','New York'],
            z = [1.0,2.0,3.0],
            colorbar = {'title':'Colorbar Title Goes Here!'})

layout = dict(geo={'scope':'usa'})

choromap = go.Figure(data = [data],layout=layout)

iplot(choromap)
1
Why the downvote? @glavia's answer solve the problem and should be accepted. - rpanai

1 Answers

0
votes

You can add 'subunitcolor': 'black' to the layout, see the Plotly documentation: https://plotly.com/python/map-configuration/#named-map-scopes-and-country-subunits.

import plotly.graph_objects as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)

data = dict(type = 'choropleth',
            locations = ['AZ','CA','NY'],
            locationmode = 'USA-states',
            colorscale = 'Jet',
            text = ['Arizon','California','New York'],
            z = [1.0,2.0,3.0],
            colorbar = {'title':'Colorbar Title Goes Here!'})

layout = dict(geo={'scope':'usa', 'subunitcolor': 'black'})

choromap = go.Figure(data=[data], layout=layout)

iplot(choromap)

enter image description here