Instagram
youtube
Facebook
Twitter

Plot 3D Surfaces Using Axes3D

Description:

A Python program that uses the Basemap toolkit from mpl_toolkits to create a simple world map with coastlines and country boundaries.

Code Explanation:

Before running this code, install Basemap and related packages using this command in your terminal:

pip install basemap matplotlib basemap-data-hires 

from mpl_toolkits.basemap import Basemap: Imports the Basemap toolkit from matplotlib.
plt.figure(...): Initializes a plot with specified size.
Basemap(projection='cyl', resolution='l'): Sets up the world map with cylindrical projection.
m.drawcoastlines(): Draws the coastlines of continents.
m.drawcountries(): Outlines the country boundaries.
m.drawmapboundary(...): Fills the oceans with light blue color.
m.fillcontinents(...): Fills the land with green and lakes with blue.
plt.title(...): Sets the title of the map.
plt.show(): Displays the final map plot.

 

Program:

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

# Create a figure and axis
plt.figure(figsize=(8, 6))

# Create a Basemap instance with cylindrical projection
m = Basemap(projection='cyl', resolution='l')

# Draw coastlines, countries, and boundaries
m.drawcoastlines()
m.drawcountries()
m.drawmapboundary(fill_color='lightblue')
m.fillcontinents(color='lightgreen', lake_color='lightblue')

# Add title
plt.title('World Map using Basemap')

# Show plot
plt.tight_layout()
plt.show()

 

Output: