Increase size of plotly choropleth window

Viewed 501

I have a dashboard I'm making with plotly Dash and I would like to increase the size of the choropleth window that shows the map without increasing the size of the figure. There's a bunch of white space above and below the map area that I want to get rid of- see in image below.

Image

**Note: In the image I zoomed in on the map to show the map window bounds clearly.

Increasing the figure size doesn't get rid of this white space. And I have the margins set to 0.

How can I expand the map area size?

Here's the code for the figure:

import pandas as pd
import plotly.express as px

dff = df.copy()
    
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
    counties_json = json.load(response)
    

fips = pd.read_csv("https://data.ny.gov/api/views/79vr-2kdi/rows.csv?accessType=DOWNLOAD&sorting=true", usecols=["County Name", "County FIPS"],
                       dtype={"fips": str})
    
fips=fips.drop_duplicates(subset="County Name")
#fips=fips[["County Name","County FIPS"]]
fips["County Name"] = fips["County Name"].str.replace("St Lawrence","St. Lawrence")
fips.loc[fips["County Name"]=="St. Lawrence","County FIPS"] = 36089
    

m = dff.groupby("COUNTY_NAME")["ACC_ID"].count().reset_index()
m = m[~(m["COUNTY_NAME"]=="Unknown") & ~(m["COUNTY_NAME"]=="Out-Of-State")]
    
m = m.set_index('COUNTY_NAME').join(fips.set_index('County Name'))
m = m.reset_index()

data = pd.DataFrame.from_dict(data)
#data=pd.read_json(cleanj_data, orient='split')
data = data.groupby("COUNTY_NAME")["ACC_ID"].count().reset_index()
data = data[~(data["COUNTY_NAME"]=="Unknown") & ~(data["COUNTY_NAME"]=="Out-Of-State")]
    
m = pd.merge(m,data,how="left",on="COUNTY_NAME")
m["ACC_ID_y"] = m["ACC_ID_y"].fillna(0)
    
    
fig = px.choropleth(m,
                    geojson=counties_json,
                    locations='County FIPS',
                    color='ACC_ID_y',
                    color_continuous_scale="blues",
                    scope="usa",
                    labels={'Name':'COUNTY_NAME', "ACC_ID_y":"Number of Samples"},
                    hover_name="COUNTY_NAME",
                    hover_data={"County FIPS":False,"ACC_ID_y":True},
                    center={"lat":43.049543,"lon":-76.149094},
                    )

fig.add_scattergeo(geojson=counties_json,
                   locations=m['County FIPS'],
                   text=m["COUNTY_NAME"],
                   mode='text',
                   textfont=dict(size=8, color="black"),
                   textposition="bottom center",
                   hoverinfo="skip")

fig.update_geos(showcountries=False,
                showcoastlines=False,
                showland=False,
                fitbounds="locations",
                visible=False)

fig.update_layout(width=850, height=600,
                  margin={"r":0,"t":0,"l":0,"b":0},
                  hoverlabel=dict(bgcolor=px.colors.sequential.Blues[8]))

0 Answers
Related