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

Plotly · Class

go.Scattergeo

go.Scattergeo is Plotly’s geographic scatter/line trace for plotting markers and paths from longitude and latitude coordinates. Its map background is controlled through the figure’s layout.geo configuration.

How it works

go.Scattergeo is a graph-object trace for plotting geographic points or paths. Supply longitude and latitude arrays, choose a display mode such as markers or lines, and configure the associated layout.geo object through figure layout or geographic update methods.

Syntax

go.Scattergeo(arg=None, **kwargs)

Key points

  • Use this trace for geographic markers and line paths.
  • Plotly Express geographic figures and graph-object geographic traces use the same geo-map system.
  • The associated go.layout.Geo object controls the base map’s appearance.

Example: Plot geographic locations

import plotly.graph_objects as go

fig = go.Figure(go.Scattergeo(
    lon=[-74.006, -0.128, 2.352],
    lat=[40.7128, 51.5072, 48.8566],
    text=["New York", "London", "Paris"],
    mode="markers",
    marker={"size": 10, "color": "crimson"},
))
fig.update_layout(geo_scope="world")
fig.show()

Creates a geographic marker trace and displays it on a world outline map.

When to use it

Geographic point maps

Plot locations such as airports, cities, or other coordinate-based entities on an outline map.

Routes and line paths

Connect ordered coordinates to visualize routes or other geographic paths.

Filled geographic shapes

Represent a region with a closed geographic trace and an interior fill.

Interview questions

QWhat is go.Scattergeo used for?

go.Scattergeo is a geographic scatter/line trace. It represents locations with longitude and latitude and can render markers, lines, or both depending on its mode.

Follow-up: How is the map background configured? Use the figure’s layout.geo object, for example through update_layout or update_geos.

QHow do you create a basic geographic plot?

Set lon and lat with corresponding geographic coordinates, then choose mode="markers" for points or mode="lines" for paths. Optional text and marker properties control labeling and appearance.

Follow-up: How would you draw a filled region? Use a closed coordinate sequence and set the scatter trace’s fill attribute to "toself".

QWhere are scope, projection, and base-map options configured?

A Scattergeo trace uses an outline-based geographic subplot, whose visual configuration is held by layout.geo. Geographic scope and projection settings can be applied there rather than on the trace itself.

Follow-up: What changed for initial geographic framing in the current major version? Geo subplots now default fitbounds to "locations", fitting the initial view to plotted locations.

  • go.layout.Geo
  • px.scatter_geo
  • px.line_geo
  • go.Choropleth

Source: Locations for outline-based maps in Python. Checked 2026-10-15.