Description Usage Arguments Value Examples
This function plots the system of equations represented by a matrix. For each row, it plots a line representing every possible two-dimensional vector that would satisfy the equation.
1 |
m |
An n x 2 matrix representing a system of equations in n dimensions |
b |
An n x 1 matrix or atomic vector representing the solutions to the equations of m. If omitted, a vector of n 0s is used, as in a homogeneous system of equations |
colors |
Optional vector of colors for the lines, one for each equation in m, reading downward. If not provided, colors are chosen automatically. If shorter than b, it is recycled per R's usual rules. If longer, extra colors are ignored. |
A ggplot object depicting the lines of the equations.
1 2 3 4 5 6 7 8 9 10 11 | m1 <- matrix(c(1,3, 2, 4), nrow =2)
m2 <- matrix(c(1, 3, 2, 6), nrow =2)
# Consistent system
plot_lines(m = m1, b = c(2, 0))
# Inconsistent system
plot_lines(m = m2, b = c(5, 7))
# Linearly dependent system - only one line appears because there are infinitely many solutions
plot_lines(m = m2, b = c(1, 2))
#Plot many equations at once
m3 <- matrix(sample(-10:10, 10), nrow = 5)
plot_lines(m = m3, b = -2:2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.