Not able to change map background color

fig = px.choropleth(
    featureidkey="properties.State",  # Match this with the key in your GeoJSON properties
    width=900,  # Set the desired width
    height=700   # Set the desired height

# Update the map to fit the GeoJSON data
fig.update_geos(fitbounds="locations", visible=False)

# Set background color to light grey
    paper_bgcolor=plot_color,  # Light grey
    plot_bgcolor=plot_color    # Light grey

# Show the map


hi @Mac
:wave: welcome to the community.

The paper_bgcolor will change the color of the outside background
The plot_bgcolor will change the background color of the plotting area in-between x and y axes, so this won’t work on maps.

Color change on scatter plot:

import as px
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
    paper_bgcolor='black',  # Change the outside background color
    plot_bgcolor='pink'     # Change the plot area background color

1 Like

Thank you Adam, Is there any other options to change background color of the map.

@Mac A map is not referenced to a cartesian system, with axes x, and y, that’s why paper_bgcolor does not work. Map are rendered in geographical coordinates.

To set your desired background color set the bgcolor in layout geo:

fig.update_geos(fitbounds='locations', visible=False, bgcolor='#1F1F1F')

and delete the lines corresponding to fig.update_layout.