Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Plotly · Module

fig.update_geos

fig.update_geos() updates geographic layout properties on a Plotly figure. Use it to control map appearance, positioning, projection, boundaries, and geographic extents.

How it works

Call fig.update_geos() to change one or more properties of the figure’s geographic layout, such as map appearance, center, projection, visible boundaries, and axis ranges. It updates the existing layout.geo configuration using the named geographic properties supplied as keyword arguments.

Syntax

fig.update_geos(...)

Parameters

NameTypeDescription
**kwargsvaries by layout.geo propertyGeographic layout properties, supplied as keyword arguments; examples include bgcolor, center_lat, center_lon, coastlinecolor, coastlinewidth, countrycolor, domain_x, fitbounds, and projection_type.

Returns

The documentation page describes the update method and its geographic properties but does not specify a separate return value.

Key points

  • The method is called directly on a Plotly figure and accepts geographic layout updates.
  • Use center_lat to specify the map’s latitude center.
  • Use center_lon to specify the map’s longitude center.
  • coastlinecolor controls the color used for coastline lines.
  • coastlinewidth controls coastline thickness in pixels and must be nonnegative.
  • countrycolor styles the lines drawn for country boundaries.

Common mistakes

  • If you do not set center_lat, Plotly derives the latitude center from the latitude range.
  • domain_x uses plot-fraction coordinates rather than geographic longitude values.

Example: Customize a geographic base map

import plotly.graph_objects as go

fig = go.Figure(go.Scattergeo(
    lat=[40.7, 51.5], lon=[-74.0, -0.1],
    mode="markers", text=["New York", "London"]
))
fig.update_geos(
    showcoastlines=True,
    showcountries=True,
    showland=True,
    landcolor="LightGreen",
    showocean=True,
    oceancolor="LightBlue",
    projection_type="natural earth"
)
fig.show()

Creates a geographic scatter plot and configures its base map, boundaries, colors, and projection.

When to use it

Style a base map

Make a geographic chart easier to read by showing coastlines, countries, land, oceans, lakes, or rivers with chosen colors.

Control map framing

Focus the viewport on a chosen latitude and longitude or constrain the displayed latitude and longitude ranges.

Select a projection

Choose an appropriate cartographic representation such as a natural-earth projection.

Fit bounds to data

Automatically fit the geographic view to plotted locations.

Interview questions

QWhat does fig.update_geos() configure?

update_geos is the figure method used to update geographic layout attributes. It accepts keyword arguments corresponding to properties documented for layout.geo, including colors, visibility flags, center, projection, and ranges.

Follow-up: How would you configure more than one geographic subplot? Use the appropriate geo layout container and its domain settings, then target the relevant geographic configuration rather than treating all maps as one plot.

QHow do you position the map?

Set center_lat and center_lon to control the map center. The documentation identifies these as numeric properties for the latitude and longitude center, respectively.

Follow-up: How can the visible geographic extent be constrained? Configure the corresponding latitude and longitude axis ranges, while using center values when you also need a controlled focal point.

QHow do you change projection and base-map styling?

Use projection_type to select the map projection, and use properties such as showcoastlines, showcountries, landcolor, and oceancolor to control the base-map presentation. These are geographic layout attributes accepted by the update method.

Follow-up: How would you make the map fit plotted locations? Set fitbounds to the documented fitting mode, such as locations, when the figure’s data should determine the displayed bounds.

  • layout.geo
  • center
  • projection
  • projection_type
  • fitbounds
  • lataxis
  • lonaxis
  • Scattergeo

Source: Python Figure Reference: layout.geo. Checked 2026-10-15.