Hi I was hoping to get some help with a problem. Iβm trying to make a choropleth map of the US with a bounding box around the actual map component. This seems to be done automatically when the scope is set to world
as shown below.
import plotly.express as px
df = px.data.election()
fig = px.choropleth(
df,
scope="world",
locations="district",
color="Bergeron")
fig.show()
The black border around just the map portion of the figure is what Iβd like to recreate when making a plot of the US, but itβs missing by default as shown below.
import plotly.express as px
df = pd.DataFrame({"State": ["NY", "CA", "TX"], "value": [10, 20, 30]})
fig = px.choropleth(
df,
locations='State',
locationmode="USA-states",
color='value',
scope="usa",
)
fig.show()
I tried manually creating a rectangle by updating the layout, which I can align properly, but as soon as I resize the window of my web browser the rectangle no longer aligns.
fig.update_layout(
shapes=[
dict(
type='rect',
xref='paper',
yref='paper',
x0=0.0, x1=1.0,
y0=0, y1=1,
line={'width': 3}
)
]
)
Any help into how to solve this would be greatly appreciated!