Contour Plot
Ocean Temperature Map
Sea surface temperature distribution showing thermal gradients and ocean current patterns.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
# Create ocean grid
np.random.seed(42)
lon = np.linspace(-180, 180, 200)
lat = np.linspace(-60, 60, 120)
LON, LAT = np.meshgrid(lon, lat)
# Temperature model with currents
T = 28 - 0.4 * np.abs(LAT)
T += 5 * np.exp(-((LON + 60)**2/400 + (LAT - 35)**2/100))
T += 4 * np.exp(-((LON - 140)**2/400 + (LAT - 30)**2/100))
T -= 4 * np.exp(-((LON + 80)**2/300 + (LAT + 20)**2/100))
T += np.random.normal(0, 0.5, T.shape)
# Ocean dark theme
plt.style.use('dark_background')
fig, ax = plt.subplots(figsize=(12, 6))
fig.patch.set_facecolor('#0a1520')
ax.set_facecolor('#0a1520')
# Custom colormap - ocean temperature
colors = ['#0a1520', '#0a2a40', '#0a4a60', '#1a6a80', '#3a8aa0',
'#5aaac0', '#8acae0', '#aaeaf0', '#ffee88', '#ffaa44', '#ff6622']
cmap = LinearSegmentedColormap.from_list('ocean_temp', colors, N=256)
# Filled contour
cf = ax.contourf(LON, LAT, T, levels=22, cmap=cmap)
# Isotherms
cs = ax.contour(LON, LAT, T, levels=10, colors='white', linewidths=0.4, alpha=0.4)
ax.clabel(cs, inline=True, fontsize=7, fmt='%.0f', colors='white')
# Styled colorbar at bottom
cbar = plt.colorbar(cf, ax=ax, pad=0.08, shrink=0.8, orientation='horizontal',
aspect=40, location='bottom')
cbar.ax.set_facecolor('#0a1520')
cbar.set_label('Sea Surface Temperature (C)', fontsize=11, color='#b0d0e0', labelpad=8)
cbar.ax.xaxis.set_tick_params(color='#b0d0e0')
cbar.outline.set_edgecolor('#2a4a5a')
plt.setp(plt.getp(cbar.ax.axes, 'xticklabels'), color='#b0d0e0', fontsize=9)
# Labels
ax.set_xlabel('Longitude', fontsize=13, color='#b0d0e0', fontweight='600', labelpad=10)
ax.set_ylabel('Latitude', fontsize=13, color='#b0d0e0', fontweight='600', labelpad=10)
ax.set_title('Global Sea Surface Temperature', fontsize=16, color='white',
fontweight='bold', pad=20)
# Style axes
ax.tick_params(colors='#8ab0c0', labelsize=10, length=0)
for spine in ax.spines.values():
spine.set_visible(False)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Pairwise Data
More Contour Plot examples
☕