Skip to content

Commit

Permalink
plotEqn() gains a ... arg
Browse files Browse the repository at this point in the history
  • Loading branch information
friendly committed Oct 20, 2024
1 parent bb3c7f2 commit 503a54f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
10 changes: 6 additions & 4 deletions R/plotEqn.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' using the character string resulting from \code{\link{showEqn}}, modified so that the
#' \code{x}s are properly subscripted.
#' @param solution logical; should the solution points for pairs of equations be marked?
#' @param ... Other arguments passed to \code{plot}
#' @return nothing; used for the side effect of making a plot
#'
#' @author Michael Friendly
Expand All @@ -45,9 +46,10 @@
plotEqn <- function(A, b, vars, xlim, ylim,
col=1:nrow(A), lwd=2, lty=1,
axes=TRUE, labels=TRUE,
solution=TRUE
solution=TRUE,
...
) {

if (!is.numeric(A) || !is.matrix(A)) stop("A must be a numeric matrix")
if (missing(b)) {
b <- A[ , ncol(A)] # assume last column of Ab
Expand Down Expand Up @@ -114,8 +116,8 @@ plotEqn <- function(A, b, vars, xlim, ylim,
}

for (i in 1:neq) {
if (i == 1) plot(xlim, ylim, type="n", xlab = vars[1], ylab = vars[2], xlim = xlim, ylim = ylim)

if (i == 1) plot(xlim, ylim, type="n", xlab = vars[1], ylab = vars[2], xlim = xlim, ylim = ylim, ...)
if (A[i, 2] == 0) {
abline(v = b[i] / A[i, 1], col = col[i], lwd = lwd[i], lty = lty[i])
y <- ylim
Expand Down
6 changes: 3 additions & 3 deletions dev/plotEqn-test.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

library(matlib)

source(here::here("dev", "plotEqn.R"))

A <- matrix(c( 1, 2, 0,
-1, 2, 1), 3, 2) |>
print()
Expand All @@ -11,9 +13,7 @@ b <- c(2, 1, 1)

showEqn(A, b, vars = c("x", "y"), simplify = TRUE)

plotEqn(A, b, vars = c("x", "y"),
cex.lab = 2,
solution = list(pch = 16))
plotEqn(A, b, vars = c("x", "y"))

# try to change the labels: doesn't work
plotEqn(A, b, vars = c("x", "y"),
Expand Down
5 changes: 4 additions & 1 deletion man/plotEqn.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 503a54f

Please sign in to comment.