plot_decomposition: Graphically Display the Orthogonal Decomposition of a...

Description Usage Arguments Value Examples

View source: R/plot_decomposition.R

Description

This function produces plots illustrating the transformation of a pair of linearly independent two-dimensional vectors into an orthogonal basis (the Q of the QR decomposition). The algorithm, which can be found in any linear algebra textbook, scales the first vector to unit length, then extracts the component of the second vector orthogonal to the first and normalizes it. The plots are based on those found on pp. 218-219 of Otto Bretscher's Linear Algebra with Applications (5th ed.).

Usage

1
2
3
4
5
6
7
8
plot_decomposition(
  m,
  color_par = "blue",
  color_perp = "red",
  color_text = "red4",
  output = "plot",
  fix_coords = FALSE
)

Arguments

m

A 2 x 2 numeric matrix of full rank, one whose columns provide a valid basis for the two-dimensional plane. If m has different dimensions, a different type, or does not have full rank, an error is thrown.

color_par

Color for the second vector's parallel component.

color_perp

Color for the second vector's orthogonal component.

color_text

Color for the text of the equations.

output

Output mode. If "plot", a single gridExtra multiplot featuring the plots side by side. If "list", a list containing the plots. Defaults to "plot."

fix_coords

Logical determining whether to draw the plots with fixed aspect ratio. Defaults to FALSE.

Value

If output is "plot", a multiplot featuring the six decomposition plots; otherwise a list containing them.

Examples

1
2
3
4
5
plot_decomposition(square(1, 4, 7, 2))
# With custom colors
plot_decomposition(square(1:4), color_par = "green", color_perp = "orange")
# Already orthogonal vectors: only scaling necessary
plot_decomposition(square(30, 20, 2, -3))

ryan-heslin/matador documentation built on Dec. 22, 2021, 8:17 p.m.