Is there a way to increase the size of the map area without increasing the size of the entire figure. In the picture below (map zoomed in to see map bounds more clearly) you can see there are large white spaces above and below the map window and increasing the size of the figure doesn’t get rid of the white space, it just makes it bigger!
Here’s the function that generates the map
def update_map(data):
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]))
return fig