Why Is My GeoPandas Plot Blank or Empty? How to Fix It
On this page
Problem statement
You call .plot() on a GeoDataFrame and nothing useful appears. The figure opens but the axes are empty, the saved image is white, or in a script no window shows at all.
What users usually mean is one of these symptoms:
- a blank figure with empty axes, often running from 0 to 1
- a window that never appears in a script
- a saved PNG that is completely white
- a choropleth with no shapes, or with holes where some features should be
- a map where the shapes are specks in a corner
In most cases, the real cause is one of these data or display issues:
- the GeoDataFrame is empty or every geometry is null
- the column used for colouring is
NaN, often after a merge whose keys did not match - two layers in different CRS share one set of axes
- the figure was never shown, or was saved after it had been closed
- the plot went to a different axes from the one you are looking at
The practical fix is to confirm the data has drawable geometry and values, then confirm the figure is actually being shown or saved. Every example below uses the US Census Bureau's 2024 county boundaries for Colorado and its county population estimates, and measures "blank" by counting the pixels in the saved image that are not white.
Quick answer
If your GeoPandas plot is blank or empty:
- Print
len(gdf),gdf.geometry.isna().sum()andgdf.geometry.is_empty.sum(). - If colouring by a column, print
gdf[column].isna().sum(); passmissing_kwdsso missing values draw grey instead of vanishing. - Check that every layer on the same axes has the same
crs. - Plot onto an explicit
fig, ax = plt.subplots()and save withfig.savefig(), notplt.savefig(). - In a script, call
plt.show()β after saving.
import geopandas as gpd
import matplotlib
matplotlib.use("Agg") # no window needed: we save files
import matplotlib.pyplot as plt
counties = gpd.read_file("data/cb_2024_us_county_500k.zip")
colorado = counties[counties["STUSPS"] == "CO"]
print("Rows:", len(colorado), "| null:", colorado.geometry.isna().sum(),
"| empty:", colorado.geometry.is_empty.sum(), "| CRS:", colorado.crs)
fig, ax = plt.subplots(figsize=(6, 4.5))
colorado.plot(ax=ax, edgecolor="black", facecolor="#bfdbfe")
print(f"ink: {ink(fig)}% of pixels not white")
fig.savefig("output/colorado.png", dpi=100)
Rows: 64 | null: 0 | empty: 0 | CRS: EPSG:4269
ink: 51.9% of pixels not white
ink() is a small helper defined with the data below: it saves the figure to memory and reports the share of pixels that are not white. A figure with only an empty frame and tick labels scores about 2%; the filled map of Colorado's 64 counties scores about 52%.
Data or display?
Empty data, null geometry, the colour column, CRS, show
Step 1: Check that the GeoDataFrame is not empty
A blank plot is often a blank dataset. A filter that matches nothing β here, a state name with a trailing space β leaves nothing to draw, and what happens next depends on the CRS:
empty = counties[counties["STATE_NAME"] == "Colorado "]
print("Rows:", len(empty))
for label, layer in [("NAD83 (degrees)", empty), ("Conus Albers (metres)", empty.to_crs(5070))]:
fig, ax = plt.subplots(figsize=(6, 4.5))
try:
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
layer.plot(ax=ax)
print(f"{label}: ink {ink(fig)}%, x axis {ax.get_xlim()}, warning: {[str(w.message) for w in caught]}")
except ValueError as err:
print(f"{label}: ValueError: {err}")
plt.close(fig)
Rows: 0
NAD83 (degrees): ValueError: aspect must be finite and positive
Conus Albers (metres): ink 2.1%, x axis (np.float64(0.0), np.float64(1.0)), warning: ['The GeoDataFrame you are attempting to plot is empty. Nothing has been displayed.']
In a geographic CRS, GeoPandas computes the axes' aspect ratio from the layer's latitude, and an empty layer has none, so the plot fails with a ValueError that says nothing about emptiness. In a projected CRS you get a warning and axes running from 0 to 1. Either way, the fix is upstream: check the file, the layer name and every filter before .plot().
Step 2: Check for null and empty geometries
A GeoDataFrame can have rows but still draw nothing if every geometry is null or empty:
nulls = colorado.assign(geometry=None)
print("Null geometries:", nulls.geometry.isna().sum(), "of", len(nulls))
try:
nulls.plot()
except ValueError as err:
print("ValueError:", err)
plt.close("all")
drawable = colorado[colorado.geometry.notna() & ~colorado.geometry.is_empty]
print("Drawable rows:", len(drawable))
Null geometries: 64 of 64
ValueError: aspect must be finite and positive
Drawable rows: 64
The same unhelpful ValueError again: in a geographic CRS it means "nothing to draw" as often as anything else. Keep only rows with real geometry before plotting; if nothing remains, the source data has no usable geometry.
Step 3: Check the column used for colouring
With column=, rows whose value is NaN are not drawn at all unless you pass missing_kwds. The way this usually happens is a merge whose keys did not match. Joining the Census estimates on a code built with astype(str) β which drops Colorado's leading zero, 08 β matches no Colorado county:
estimates = pd.read_csv("data/co-est2024-alldata.csv", encoding="latin-1")
estimates["GEOID"] = (estimates["STATE"] * 1000 + estimates["COUNTY"]).astype(str) # "8001", not "08001"
broken = colorado.merge(estimates[["GEOID", "POPESTIMATE2024"]], on="GEOID", how="left")
print("NaN populations:", broken["POPESTIMATE2024"].isna().sum(), "of", len(broken))
fig, ax = plt.subplots(figsize=(6, 4.5))
broken.plot(ax=ax, column="POPESTIMATE2024")
print(f"column= only: ink {ink(fig)}%, x axis {ax.get_xlim()}")
plt.close(fig)
fig, ax = plt.subplots(figsize=(6, 4.5))
broken.plot(ax=ax, column="POPESTIMATE2024", missing_kwds={"color": "lightgrey", "label": "no data"})
print(f"with missing_kwds: ink {ink(fig)}%")
plt.close(fig)
NaN populations: 64 of 64
column= only: ink 1.9%, x axis (np.float64(0.0), np.float64(1.0))
with missing_kwds: ink 51.4%
The first map is an empty frame from 0 to 1 β every county was skipped, and nothing warns. With missing_kwds, the counties draw grey, which shows at once that the data is missing rather than the map. The real fix is the key: .str.zfill(5).
Step 4: Check the CRS of every layer on the axes
Two layers in different CRS on one axes both draw, just in different places:
fig, ax = plt.subplots(figsize=(6, 4.5))
colorado.to_crs(5070).plot(ax=ax, color="tab:blue") # metres, around x = -1,000,000
colorado.plot(ax=ax, color="tab:red") # degrees, around x = -105
print(f"ink {ink(fig)}%, x axis {[round(v) for v in ax.get_xlim()]}")
plt.close(fig)
ink 3.4%, x axis [-1203799, 57217]
The axes stretch to cover both, so each layer shrinks to a speck β one near x = β1 million, the other near 0. Reproject one layer to the other's CRS before plotting them together.
Step 5: Make sure the figure is shown or saved
In a plain script, building a plot does not show it: call plt.show() to open a window, or save the figure. When saving, name the figure you mean:
fig, ax = plt.subplots(figsize=(6, 4.5))
colorado.plot(ax=ax, edgecolor="black")
plt.close(fig) # what closing the window after plt.show() does
plt.savefig("output/current_figure.png", dpi=100)
fig.savefig("output/this_figure.png", dpi=100)
print(f"plt.savefig: {ink_of('output/current_figure.png')}% ink | fig.savefig: {ink_of('output/this_figure.png')}% ink")
plt.close("all")
plt.savefig: 0.0% ink | fig.savefig: 51.9% ink
plt.savefig() saves the current figure. Once the map's figure is closed β as it is when you close the window that plt.show() opened β there is no current figure, so Matplotlib makes a new, empty one and saves that: a completely white PNG. fig.savefig() saves the figure you built, whatever happened to the window. Save first, then show.
In Jupyter, the inline backend renders a figure at the end of the cell, so a missing plt.show() is rarely the problem there.
Step 6: Plot onto an explicit axes
If you reuse an ax from an earlier figure, your data goes onto axes you are not looking at. Create the figure and axes together and pass ax=:
fig, (left, right) = plt.subplots(1, 2, figsize=(9, 4))
colorado.plot(ax=left, edgecolor="black")
print(f"left: {len(left.collections)} collection(s) | right: {len(right.collections)} collection(s)")
plt.close(fig)
left: 1 collection(s) | right: 0 collection(s)
Counting the collections on each axes is a direct test of where the shapes went.
A pre-plot diagnostic for Colorado counties
The data used on this page
- County boundaries β the Census Bureau's 2024 cartographic boundary file (
cb_2024_us_county_500k), of which Colorado's 64 counties are used, in NAD83. - County population estimates β the Census Bureau's Vintage 2024
co-est2024-alldata.csv, whoseSTATEandCOUNTYcodes pandas reads as integers.
The block also defines ink(), which measures how much of a figure is not white.
import io
import os
import warnings
import geopandas as gpd
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import pandas as pd
import requests
os.makedirs("data", exist_ok=True)
os.makedirs("output", exist_ok=True)
files = {
"cb_2024_us_county_500k.zip": "https://www2.census.gov/geo/tiger/GENZ2024/shp/cb_2024_us_county_500k.zip",
"co-est2024-alldata.csv": "https://www2.census.gov/programs-surveys/popest/datasets/2020-2024/counties/totals/"
"co-est2024-alldata.csv",
}
for name, url in files.items():
if not os.path.exists("data/" + name):
reply = requests.get(url, timeout=300)
reply.raise_for_status()
open("data/" + name, "wb").write(reply.content)
def ink_of(png):
"""Share of pixels in a PNG that are not (near) white, in percent."""
pixels = plt.imread(png)[..., :3]
return round(float((pixels.min(axis=2) < 0.95).mean() * 100), 1)
def ink(fig):
buffer = io.BytesIO()
fig.savefig(buffer, format="png", dpi=100)
buffer.seek(0)
return ink_of(buffer)
counties = gpd.read_file("data/cb_2024_us_county_500k.zip")
colorado = counties[counties["STUSPS"] == "CO"]
fig, ax = plt.subplots(figsize=(6, 4.5))
print("empty axes:", ink(fig), "% ink")
plt.close(fig)
empty axes: 2.3 % ink
Example 1: A diagnostic to run before any plot
def diagnose(gdf, column=None):
report = {"rows": len(gdf), "null": int(gdf.geometry.isna().sum()),
"empty": int(gdf.geometry.is_empty.sum()), "crs": str(gdf.crs)}
if len(gdf) and not gdf.geometry.isna().all():
report["bounds"] = gdf.total_bounds.round(2).tolist()
if column is not None:
report[f"{column} NaN"] = int(gdf[column].isna().sum())
return report
print(diagnose(colorado))
print(diagnose(counties[counties["STATE_NAME"] == "Colorado "]))
print(diagnose(broken, "POPESTIMATE2024"))
{'rows': 64, 'null': 0, 'empty': 0, 'crs': 'EPSG:4269', 'bounds': [-109.06, 36.99, -102.04, 41.0]}
{'rows': 0, 'null': 0, 'empty': 0, 'crs': 'EPSG:4269'}
{'rows': 64, 'null': 0, 'empty': 0, 'crs': 'EPSG:4269', 'bounds': [-109.06, 36.99, -102.04, 41.0], 'POPESTIMATE2024 NaN': 64}
Each of the three reports points at a different cause before a figure has been made.
Example 2: A choropleth that cannot silently go blank
estimates = pd.read_csv("data/co-est2024-alldata.csv", encoding="latin-1", dtype={"STATE": str, "COUNTY": str})
estimates["GEOID"] = estimates["STATE"] + estimates["COUNTY"]
fixed = colorado.merge(estimates[["GEOID", "POPESTIMATE2024"]], on="GEOID", how="left").to_crs(5070)
print("NaN populations:", fixed["POPESTIMATE2024"].isna().sum())
fig, ax = plt.subplots(figsize=(7, 5))
fixed.plot(ax=ax, column="POPESTIMATE2024", scheme="quantiles", k=5, legend=True, edgecolor="white", linewidth=0.4,
missing_kwds={"color": "lightgrey", "label": "no data"}, legend_kwds={"title": "residents, 2024"})
ax.set_axis_off()
fig.savefig("output/colorado_population.png", dpi=100, bbox_inches="tight")
print(f"ink {ink_of('output/colorado_population.png')}%")
plt.close(fig)
NaN populations: 0
ink 63.6%
missing_kwds means a failed join shows up as grey counties with a "no data" entry in the legend instead of an empty frame, and the explicit fig.savefig writes this figure whatever else is open. (scheme= needs the mapclassify package.)
Axes drawn, geometry missing
A GeoPandas plot has two separate parts: the Matplotlib axes and the geometry drawn onto them. A blank figure means the axes were created but no geometry reached them, or the figure was never shown.
The most common causes are:
-
no drawable geometry An empty GeoDataFrame, or one whose geometries are all null or empty. In a projected CRS this gives empty axes and a warning; in a geographic CRS,
ValueError: aspect must be finite and positive. -
NaNin the colour column Withcolumn=, features whose value isNaNare skipped. When every value isNaNβ typically after a merge with mismatched keys β nothing is drawn and nothing warns. -
layers in different CRS Both draw, far apart, so each is a speck on axes stretched to hold both.
-
the figure was never shown, or the wrong one was saved In a script,
plt.show()is what opens the window.plt.savefig()after the figure has been closed saves a new, empty one. -
wrong axes Passing a reused
axsends the geometry to a figure you are not viewing.
The key distinction is between empty axes and empty data. Axes running from 0 to 1 mean nothing reached them: a data problem. Axes in real coordinates with nothing visible mean the data is there but too small, off to one side, or unfilled.
Jupyter, backends and a single point
Jupyter versus a script
In Jupyter, the inline backend renders a figure at the end of a cell, so a missing plt.show() is rarely the issue. In a plain script you need plt.show() to see a window.
Interactive backends
If plt.show() returns at once without a window, you probably have a non-interactive backend such as Agg β the default on a machine with no display. Check with matplotlib.get_backend(), and save the figure instead.
Saving versus showing
Save before you show, and save with fig.savefig(). Step 5 measured the difference: after the figure was closed, plt.savefig() wrote a white image and fig.savefig() wrote the map.
All geometries filtered out
A chained filter such as gdf[gdf["area"] > 1000] can quietly return zero rows. Print len() after each filter so you know when the data became empty.
A single point looks like nothing
One point draws as one default-size marker, a few pixels across, in the middle of axes scaled to fit it. Increase markersize or set explicit limits.
Internal links
- How to Plot Maps in Python with GeoPandas and Matplotlib
- How to Save a Map as an Image in Python with Matplotlib
- Why Does My GeoPandas Map Look Upside Down?
- How to Remove Null and Empty Geometries in GeoPandas
- Cannot Transform Naive Geometries to CRS: How to Fix It in GeoPandas
- How to Create a Choropleth Map in Python with GeoPandas
FAQ
Why is my GeoPandas plot blank?
Usually because there is no drawable geometry, the colour column is all NaN, or the figure was never shown. Check len(gdf), gdf.geometry.isna().sum(), gdf.geometry.is_empty.sum() and the column's isna().sum(), then make sure you call plt.show() or fig.savefig().
Why does nothing appear when I run .plot() in a script?
Building a plot does not display it. In a script you need plt.show() to open a window, or savefig() to write the figure to a file.
Why is my choropleth map all one color or blank?
Features whose column= value is NaN are not drawn, so a column that is all NaN gives an empty frame and a partly-NaN one gives holes. Check the column with isna().sum() β a failed merge is the usual cause β and pass missing_kwds to draw missing values grey.
Why is my saved map image completely white?
Either the figure had nothing to draw, or plt.savefig() ran after the figure was closed and saved a new, empty one. Save with fig.savefig() before plt.show().
Why does my GeoPandas plot show axes with coordinate numbers but no shapes?
The axes rendered, so this is a data problem, not a display one: the geometry is null, empty, or filtered out. Run gdf.geometry.notna().sum() and (~gdf.geometry.is_empty).sum() to confirm there is something drawable before plotting.
Why do two layers plot in different places or one disappears off-screen?
The layers are almost certainly in different CRS, so their coordinate ranges do not overlap and one falls outside the visible extent. Reproject one to match the other with layer2 = layer2.to_crs(layer1.crs) before plotting them on the same ax.
Why is my plot blank only when I save with savefig but fine on screen?
You likely called plt.savefig() after plt.show(): closing the window closes the figure, and plt.savefig() then saves a new, empty current figure. Save first with the explicit fig.savefig("map.png"), then show.
How do I make a single point or tiny feature visible instead of an empty-looking plot?
A lone point can render too small to see at the default scale. Increase markersize and set explicit limits, for example gdf.plot(markersize=50) followed by ax.set_xlim(...), or buffer the point so it has visible area.