Wind Barb Plots with barbs(X, Y, U, V)ΒΆ
Wind barbs are a specialized meteorological visualization that encodes both wind speed and direction at grid points using a standardized symbology. The Axes.barbs() method takes grid coordinates (X, Y) and vector components (U, V), then renders barb symbols where the orientation shows wind direction and the flags/lines on the barb encode speed in knots (short lines = 5 knots, long lines = 10 knots, filled triangles = 50 knots).
Why this matters for data science: Wind barbs are the standard notation used in weather maps and meteorological data analysis worldwide. If you work with atmospheric data, climate models, or any geospatial vector field with a magnitude convention, barbs provide a compact and information-dense alternative to quiver arrows. The example constructs a vector field from amplitude and angle arrays, then decomposes them into U and V components using np.sin() and np.cos(). The barbcolor, flagcolor, length, and linewidth parameters give fine-grained control over the visual appearance. Note the use of degree-to-radian conversion (np.pi / 180), which is a common requirement when working with angular data from real-world sources.
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('_mpl-gallery-nogrid')
# make data:
X, Y = np.meshgrid([1, 2, 3, 4], [1, 2, 3, 4])
angle = np.pi / 180 * np.array([[15., 30, 35, 45],
[25., 40, 55, 60],
[35., 50, 65, 75],
[45., 60, 75, 90]])
amplitude = np.array([[5, 10, 25, 50],
[10, 15, 30, 60],
[15, 26, 50, 70],
[20, 45, 80, 100]])
U = amplitude * np.sin(angle)
V = amplitude * np.cos(angle)
# plot:
fig, ax = plt.subplots()
ax.barbs(X, Y, U, V, barbcolor='C0', flagcolor='C0', length=7, linewidth=1.5)
ax.set(xlim=(0, 4.5), ylim=(0, 4.5))
plt.show()