Matplotlib Basemap Toolkit

2.0.0 · deprecated · verified Fri Apr 17

Basemap is a deprecated Python library for plotting 2D data on map projections with Matplotlib. While it enabled various map projections, coastlines, and geopolitical boundaries, it is no longer actively developed and is officially superseded by Cartopy. The current version is 2.0.0.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a Basemap instance with a 'mill' (Miller cylindrical) projection, draw basic map features like coastlines and meridians, and save the output to a file. Remember that Basemap is deprecated.

import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

# Create a new figure
fig = plt.figure(figsize=(8, 6))

# Create a Basemap instance for a global cylindrical projection
m = Basemap(projection='mill', llcrnrlat=-90, urcrnrlat=90,
            llcrnrlon=-180, urcrnrlon=180, resolution='l')

# Draw coastlines, countries, parallels, and meridians
m.drawcoastlines()
m.drawcountries()
m.drawparallels(range(-90, 91, 30))
m.drawmeridians(range(-180, 181, 60))

plt.title("Simple Basemap Example (Deprecated)")

# Save the plot instead of showing it for script execution
plt.savefig("basemap_example.png")
print("Basemap example plot saved to basemap_example.png")

view raw JSON →