Contour Plot
Weather Pressure Systems
Synoptic weather map showing high and low pressure systems with isobars.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
# Create weather grid
np.random.seed(42)
x = np.linspace(0, 100, 200)
y = np.linspace(0, 80, 160)
X, Y = np.meshgrid(x, y)
# Pressure systems (hPa)
P = 1013 + np.zeros_like(X)
P += 20 * np.exp(-((X-70)**2 + (Y-50)**2)/400)
P -= 25 * np.exp(-((X-25)**2 + (Y-35)**2)/300)
P += 10 * np.exp(-((X-50)**2 + (Y-70)**2)/200)
P += 2 * np.sin(X/10) * np.cos(Y/8)
# Weather dark theme
plt.style.use('dark_background')
fig, ax = plt.subplots(figsize=(12, 8))
fig.patch.set_facecolor('#0f1525')
ax.set_facecolor('#0f1525')
# Custom colormap - pressure blue to red
colors = ['#1a4aff', '#3a6aff', '#5a8aff', '#8abaff', '#bae0ff',
'#ffffff', '#ffe0ba', '#ffba8a', '#ff8a5a', '#ff5a3a', '#ff2a1a']
cmap = LinearSegmentedColormap.from_list('pressure', colors, N=256)
# Filled contour
levels = np.linspace(985, 1035, 25)
cf = ax.contourf(X, Y, P, levels=levels, cmap=cmap)
# Isobars
cs = ax.contour(X, Y, P, levels=np.arange(988, 1036, 4), colors='white',
linewidths=0.7, alpha=0.6)
ax.clabel(cs, inline=True, fontsize=9, fmt='%.0f', colors='white')
# Mark H and L with glow
ax.text(70, 50, 'H', fontsize=32, color='#ff5a3a', fontweight='bold',
ha='center', va='center', zorder=6)
ax.text(70, 50, 'H', fontsize=36, color='#ff5a3a', fontweight='bold',
ha='center', va='center', alpha=0.3, zorder=5)
ax.text(25, 35, 'L', fontsize=32, color='#3a6aff', fontweight='bold',
ha='center', va='center', zorder=6)
ax.text(25, 35, 'L', fontsize=36, color='#3a6aff', fontweight='bold',
ha='center', va='center', alpha=0.3, zorder=5)
# Styled colorbar
cbar = plt.colorbar(cf, ax=ax, pad=0.02, shrink=0.85)
cbar.ax.set_facecolor('#0f1525')
cbar.set_label('Pressure (hPa)', fontsize=11, color='#d0d8e8', labelpad=10)
cbar.ax.yaxis.set_tick_params(color='#d0d8e8')
cbar.outline.set_edgecolor('#2a3a5a')
plt.setp(plt.getp(cbar.ax.axes, 'yticklabels'), color='#d0d8e8', fontsize=9)
# Labels
ax.set_xlabel('Distance (km)', fontsize=13, color='#d0d8e8', fontweight='600', labelpad=10)
ax.set_ylabel('Distance (km)', fontsize=13, color='#d0d8e8', fontweight='600', labelpad=10)
ax.set_title('Synoptic Weather Map', fontsize=16, color='white', fontweight='bold', pad=20)
# Style axes
ax.tick_params(colors='#a0b0c8', 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
☕