plot_mat: Plot The Vectors of a Matrix

Description Usage Arguments Details Value Examples

View source: R/plot_mat.R

Description

This function plots the column vectors of a two-dimensional matrix.

Usage

1
plot_mat(m, fix_coords = FALSE, lims_scale = 1, ...)

Arguments

m

A 2 x m matrix. Rows are assumed to represent dimensions.

fix_coords

Logical determining the plot's aspect ratio. If TRUE, the plot is scaled to have an aspect ratio of 1, meaning the x and y dimensions are scaled exactly the same. Note this will distort the size of the plot and will result in unreadable plots if the ranges of x and y are disparate. Defaults to FALSE.

lims_scale

Scaling factor to apply to plot limits. For example, setting this argument to 2 doubles the default limits in each dimension. If less than 1 in absolute value, some of the plotted vectors are cut off and a message is generated. Defaults to 1.

...

Vectors of aesthetics to guide how geom_segment draws the plot: color, alpha, linetype, and size. Default to "black", 1, "solid", and 1, respectively. An error is thrown if any argument of ... has a different name, or if a valid name is used more than once. These arguments are not validated; if invalid values are chosen, geom_segment will throw an error when it attempts to interpret them. If less than or greater than m, recycled or truncated by R's standard rules.

Details

@param color governs the color of the arrowhead plotted at the tip of each vector, and @param size determines the size.

Value

A ggplot object plotting each vector encoded in the provided matrix.

Examples

1
2
3
plot_mat(rbind(-10:0, 0:10))
# Very ugly plot of the standard vectors
plot_mat(diag(nrow =2), size = c(2, 3), color = c("purple", "orange"))

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