From 91cbe686de9d97b56ed233a231d8f32915e631d2 Mon Sep 17 00:00:00 2001 From: Michael Friendly Date: Sat, 10 Feb 2024 17:41:20 -0500 Subject: [PATCH] fix vectors buglet; bump pkg vers.; add ORCIDs --- DESCRIPTION | 15 ++++++++------- NAMESPACE | 3 +++ R/circle.R | 15 ++++++++++----- R/vectors.R | 2 +- man/circle.Rd | 11 +++++++---- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 34d20793..c9919e4c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,13 +2,14 @@ Package: matlib Type: Package Title: Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics -Version: 0.9.7 -Date: 2023-03-08 -Authors@R: c(person(given = "Michael", family = "Friendly", role=c("aut", "cre"), email="friendly@yorku.ca", - comment=c(ORCID="0000-0002-3237-0941")), - person(given = "John", family = "Fox", role="aut"), - person(given = "Phil", family = "Chalmers", role="aut"), - person(given = "Georges", family = "Monette", role="ctb"), +Version: 0.9.8 +Date: 2024-02-10 +Authors@R: c(person(given = "Michael", family = "Friendly", + role=c("aut", "cre"), email="friendly@yorku.ca", + comment=c(ORCID="0000-0002-3237-0941")), + person(given = "John", family = "Fox", role="aut", comment = c(ORCID = "0000-0002-1196-8012")), + person(given = "Phil", family = "Chalmers", role="aut", comment = c(ORCID="0000-0001-5332-2810")), + person(given = "Georges", family = "Monette", role="ctb", comment = c(ORCID = "0000-0003-0076-5532")), person(given = "Gaston", family = "Sanchez", role="ctb") ) Maintainer: Michael Friendly diff --git a/NAMESPACE b/NAMESPACE index 4bd50fe2..5fcefae9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -72,12 +72,15 @@ import(stats) importFrom(MASS,fractions) importFrom(car,dataEllipse) importFrom(grDevices,adjustcolor) +importFrom(grDevices,dev.cur) importFrom(grDevices,rainbow) importFrom(graphics,abline) importFrom(graphics,arrows) importFrom(graphics,lines) +importFrom(graphics,par) importFrom(graphics,plot) importFrom(graphics,points) +importFrom(graphics,polygon) importFrom(graphics,symbols) importFrom(graphics,text) importFrom(methods,is) diff --git a/R/circle.R b/R/circle.R index 70b9da38..98ee871e 100644 --- a/R/circle.R +++ b/R/circle.R @@ -4,15 +4,17 @@ #' Draw circles on an existing plot. #' #' @details -#' Rather than depending on the aspect ratio set in the call to \code{\link[base]{plot}}, -#' \code{circle} uses the dimensions of the plot and the \code{x} and \code{y} coordinates to draw a circle rather than an ellipse. +#' Rather than depending on the aspect ratio \code{par("asp")} set globally or +#' in the call to \code{\link[base]{plot}}, +#' \code{circle} uses the dimensions of the current plot and the \code{x} and \code{y} coordinates to draw a circle rather than an ellipse. +#' Of course, if you resize the plot the aspect ratio can change. #' -#' This function was copied from +#' This function was copied from \code{\link[plotrix]{draw.circle}} #' #' @param x,y Coordinates of the center of the circle. #' @param radius Radius (or radii) of the circle(s) in user units. #' @param nv Number of vertices to draw the circle. -#' @param border Color to use for drawing the circumference. +#' @param border Color to use for drawing the circumference. \code{\link[graphics]{polygon}} #' @param col Color to use for filling the circle. #' @param lty Line type for the circumference. #' @param density Density for patterned fill. See \code{\link[graphics]{polygon}}. @@ -20,6 +22,7 @@ #' @param lwd Line width for the circumference. #' #' @return Invisibly returns a list with the \code{x} and \code{y} coordinates of the points on the circumference of the last circle displayed. +#' @importFrom graphics polygon #' @export #' @seealso \code{\link[graphics]{polygon}} #' @author Jim Lemon, thanks to David Winsemius for the density and angle args @@ -31,6 +34,7 @@ #' # draw three concentric circles #' circle(2, 4, c(1, 0.66, 0.33),border="purple", #' col=c("#ff00ff","#ff77ff","#ffccff"),lty=1,lwd=1) +#' # draw some others #' circle(2.5, 8, 0.6,border="red",lty=3,lwd=3) #' circle(4, 3, 0.7,border="green",col="yellow",lty=1, #' density=5,angle=30,lwd=10) @@ -74,7 +78,8 @@ circle <- function(x, y, #' \code{getYmult} retrieves the plot aspect ratio and the coordinate ratio for the current graphics device, calculates a #' multiplicative factor to equalize the X and Y dimensions of a plotted graphic object. #' -#' +#' @importFrom grDevices dev.cur +#' @importFrom graphics par #' @return The correction factor for the Y dimension. #' @author Jim Lemon #' @export diff --git a/R/vectors.R b/R/vectors.R index 2a0a49e0..c980fca5 100644 --- a/R/vectors.R +++ b/R/vectors.R @@ -51,8 +51,8 @@ vectors <- function(X, origin=c(0,0), if (is.vector(X)) X <- matrix(X, ncol=2) vl <- len(t(X)) < 1e-4 + ok <- !vl if (any(vl)) { - ok <- !vl warning("Row(s) ", paste(which(vl), collapse=', '), " are too small to draw and have been ignored.") } .arrows(origin[1], origin[2], X[ok,1], X[ok,2], lwd=lwd, length=length, angle=angle, ...) diff --git a/man/circle.Rd b/man/circle.Rd index 54865f63..138cf78f 100644 --- a/man/circle.Rd +++ b/man/circle.Rd @@ -24,7 +24,7 @@ circle( \item{nv}{Number of vertices to draw the circle.} -\item{border}{Color to use for drawing the circumference.} +\item{border}{Color to use for drawing the circumference. \code{\link[graphics]{polygon}}} \item{col}{Color to use for filling the circle.} @@ -43,10 +43,12 @@ Invisibly returns a list with the \code{x} and \code{y} coordinates of the point Draw circles on an existing plot. } \details{ -Rather than depending on the aspect ratio set in the call to \code{\link[base]{plot}}, -\code{circle} uses the dimensions of the plot and the \code{x} and \code{y} coordinates to draw a circle rather than an ellipse. +Rather than depending on the aspect ratio \code{par("asp")} set globally or +in the call to \code{\link[base]{plot}}, +\code{circle} uses the dimensions of the current plot and the \code{x} and \code{y} coordinates to draw a circle rather than an ellipse. +Of course, if you resize the plot the aspect ratio can change. -This function was copied from +This function was copied from \code{\link[plotrix]{draw.circle}} } \examples{ plot(1:5,seq(1,10,length=5), @@ -55,6 +57,7 @@ plot(1:5,seq(1,10,length=5), # draw three concentric circles circle(2, 4, c(1, 0.66, 0.33),border="purple", col=c("#ff00ff","#ff77ff","#ffccff"),lty=1,lwd=1) +# draw some others circle(2.5, 8, 0.6,border="red",lty=3,lwd=3) circle(4, 3, 0.7,border="green",col="yellow",lty=1, density=5,angle=30,lwd=10)