From 503a54f408d631a9668b8a61f3e274cad64f1220 Mon Sep 17 00:00:00 2001 From: Michael Friendly Date: Sat, 19 Oct 2024 21:56:13 -0400 Subject: [PATCH] plotEqn() gains a ... arg --- R/plotEqn.R | 10 ++++++---- dev/plotEqn-test.R | 6 +++--- man/plotEqn.Rd | 5 ++++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/R/plotEqn.R b/R/plotEqn.R index 35b77e4e..2ee5e562 100644 --- a/R/plotEqn.R +++ b/R/plotEqn.R @@ -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 @@ -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 @@ -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 diff --git a/dev/plotEqn-test.R b/dev/plotEqn-test.R index 57d2bc5a..d1ae6ad4 100644 --- a/dev/plotEqn-test.R +++ b/dev/plotEqn-test.R @@ -2,6 +2,8 @@ library(matlib) +source(here::here("dev", "plotEqn.R")) + A <- matrix(c( 1, 2, 0, -1, 2, 1), 3, 2) |> print() @@ -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"), diff --git a/man/plotEqn.Rd b/man/plotEqn.Rd index 9fa6ef48..944b8ff3 100644 --- a/man/plotEqn.Rd +++ b/man/plotEqn.Rd @@ -15,7 +15,8 @@ plotEqn( lty = 1, axes = TRUE, labels = TRUE, - solution = TRUE + solution = TRUE, + ... ) } \arguments{ @@ -47,6 +48,8 @@ using the character string resulting from \code{\link{showEqn}}, modified so tha \code{x}s are properly subscripted.} \item{solution}{logical; should the solution points for pairs of equations be marked?} + +\item{...}{Other arguments passed to \code{plot}} } \value{ nothing; used for the side effect of making a plot