Introduction
A list of (x, y) pairs is hard to reason about — but the same values drawn as arrows from the origin instantly show you which vectors point in similar directions, which are longer or shorter, and how they relate geometrically. PlotVectors takes a collection of 2D vectors and renders them on a labeled coordinate plane, automatically scaling the axes so every vector is visible and applying a Seaborn color palette so multiple vectors stay visually distinct.
Teaching Note
Visualizing vectors is essential for:
- Mapping movement patterns or displacement offsets
- Visualizing feature embeddings or PCA components in 2D space
- Representing the magnitude and direction of economic shifts
- Modeling force vectors or directional threats in a perimeter
- Explaining linear combinations and vector operations
- Analyzing stress or load directions in structural simplifies
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
list_of_vectorsrequired | | — | A list of 2D vectors. Each vector can be represented as a list or a numpy.ndarray (e.g., [x, y]). |
list_of_vector_labels | | None | A list of string labels corresponding to each vector. If None, default labels (e.g., 'Vector 0', 'Vector 1') are generated. Defaults to None. |
color_palette | | 'Set2' | The name of the Seaborn color palette to use for styling the vectors. Defaults to 'Set2'. |
Returns
None — the function renders a plot directly to the active window using plt.show().
Example
python
from analysistoolbox.linear_algebra import PlotVectors
# Plot basic unit vectors
PlotVectors([[1, 0], [0, 1]], ['Unit X', 'Unit Y'])