diff --git a/NEWS.md b/NEWS.md index b37bd46..08b8620 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ - Consolidate options for `print.latexMatrix` - Fix bug in `print.latexMatrix(sparse=TRUE)` - `plotEqn()` gains a `...` to pass other graphical parameters +- added `coffee` data (modified from `spida2`) # matlib 1.0.0 diff --git a/R/vectors3d.R b/R/vectors3d.R index b8d4889..6c5c15b 100644 --- a/R/vectors3d.R +++ b/R/vectors3d.R @@ -56,13 +56,8 @@ #' rgl.bringtotop() vectors3d <- function(X, origin=c(0,0,0), - color, - headlength=0.035, ref.length=NULL, radius=1/60, - labels=TRUE, - cex.lab=1.2, adj.lab=0.5, frac.lab=1.1, - draw=TRUE, - col.lab = col, - ...) { + headlength=0.035, ref.length=NULL, radius=1/60, + labels=TRUE, cex.lab=1.2, adj.lab=0.5, frac.lab=1.1, draw=TRUE, ...) { if (is.vector(X)) X <- matrix(X, ncol=3) n <- nrow(X) @@ -71,10 +66,7 @@ vectors3d <- function(X, origin=c(0,0,0), scale <- c(1, 1, 1) # radius <- 1/60 - ref.length <- arrows3d(OX, - color = color, - headlength=headlength, - scale=scale, radius=radius, + ref.length <- arrows3d(OX, headlength=headlength, scale=scale, radius=radius, ref.length=ref.length, draw=draw, ...) if (draw){ @@ -88,11 +80,7 @@ vectors3d <- function(X, origin=c(0,0,0), xl = origin[1] + frac.lab * (X[,1]-origin[1]) yl = origin[2] + frac.lab * (X[,2]-origin[2]) zl = origin[3] + frac.lab * (X[,3]-origin[3]) - # can't pass color to plotmath3d() - text3d(xl, yl, zl, labels, cex=cex.lab, adj=adj.lab, -# usePlotmath = is.expression(labels), -# color = col.lab, - ...) + text3d(xl, yl, zl, labels, cex=cex.lab, adj=adj.lab, ...) } } invisible(c(ref.length=ref.length)) diff --git a/dev/test-vectors3d.R b/dev/test-vectors3d.R index 1ed7df6..6c78a57 100644 --- a/dev/test-vectors3d.R +++ b/dev/test-vectors3d.R @@ -10,7 +10,7 @@ library(matlib) labs <- c(expression(x[1]), "y", expression(x[2])) is.expression(labs) -source(here::here("dev", "vectors3d.R")) +#source(here::here("dev", "vectors3d.R")) open3d() E <- diag(3) diff --git a/dev/vectors3d.R b/dev/vectors3d.R index 6c5c15b..490dbe3 100644 --- a/dev/vectors3d.R +++ b/dev/vectors3d.R @@ -9,6 +9,7 @@ #' #' @param X a vector or three-column matrix representing a set of geometric vectors; if a matrix, one vector is drawn for each row #' @param origin the origin from which they are drawn, a vector of length 3. +#' @param color color for the geometric vectors, recycled as necessary for the rows of \code{X}. #' @param headlength the \code{headlength} argument passed to \code{\link{arrows3d}} determining the length of arrow heads #' @param ref.length vector length to be used in scaling arrow heads so that they are all the same size; if \code{NULL} #' the longest vector is used to scale the arrow heads @@ -20,6 +21,7 @@ #' @param adj.lab label position relative to the label point as in \code{\link[rgl]{text3d}}, recycled as necessary. #' @param frac.lab location of label point, as a fraction of the distance between \code{origin} and \code{X}, recycled as necessary. #' Values \code{frac.lab > 1} locate the label beyond the end of the vector. +#' @param col.lab color for labels #' @param draw if \code{TRUE} (the default), draw the vector(s). #' @param ... other arguments passed on to graphics functions. #' @@ -56,8 +58,13 @@ #' rgl.bringtotop() vectors3d <- function(X, origin=c(0,0,0), - headlength=0.035, ref.length=NULL, radius=1/60, - labels=TRUE, cex.lab=1.2, adj.lab=0.5, frac.lab=1.1, draw=TRUE, ...) { + color = rep("black", nrow(X)), + headlength=0.035, ref.length=NULL, radius=1/60, + labels=TRUE, + cex.lab=1.2, adj.lab=0.5, frac.lab=1.1, + col.lab = col, + draw=TRUE, + ...) { if (is.vector(X)) X <- matrix(X, ncol=3) n <- nrow(X) @@ -66,7 +73,10 @@ vectors3d <- function(X, origin=c(0,0,0), scale <- c(1, 1, 1) # radius <- 1/60 - ref.length <- arrows3d(OX, headlength=headlength, scale=scale, radius=radius, + ref.length <- arrows3d(OX, + color = color, + headlength=headlength, + scale=scale, radius=radius, ref.length=ref.length, draw=draw, ...) if (draw){ @@ -80,7 +90,11 @@ vectors3d <- function(X, origin=c(0,0,0), xl = origin[1] + frac.lab * (X[,1]-origin[1]) yl = origin[2] + frac.lab * (X[,2]-origin[2]) zl = origin[3] + frac.lab * (X[,3]-origin[3]) - text3d(xl, yl, zl, labels, cex=cex.lab, adj=adj.lab, ...) + # can't pass color to plotmath3d() + text3d(xl, yl, zl, labels, cex=cex.lab, adj=adj.lab, +# usePlotmath = is.expression(labels), + color = col.lab, + ...) } } invisible(c(ref.length=ref.length)) diff --git a/man/coffee.Rd b/man/coffee.Rd index 9b7bb4b..1a382fb 100644 --- a/man/coffee.Rd +++ b/man/coffee.Rd @@ -12,7 +12,6 @@ and \code{Stress}, a measure of perceived occupational stress, in a contrived sample of \eqn{n = 20} university people. } -} \usage{data("coffee")} \format{ A data frame with 20 observations on the following 4 variables. diff --git a/man/vectors3d.Rd b/man/vectors3d.Rd index d7886f1..37c3e08 100644 --- a/man/vectors3d.Rd +++ b/man/vectors3d.Rd @@ -7,7 +7,6 @@ vectors3d( X, origin = c(0, 0, 0), - color, headlength = 0.035, ref.length = NULL, radius = 1/60, @@ -16,7 +15,6 @@ vectors3d( adj.lab = 0.5, frac.lab = 1.1, draw = TRUE, - col.lab = col, ... ) } diff --git a/vignettes/latex-equations.Rmd b/vignettes/latex-equations.Rmd index 906a87a..9221825 100644 --- a/vignettes/latex-equations.Rmd +++ b/vignettes/latex-equations.Rmd @@ -3,9 +3,6 @@ title: "LaTeX Equations with latexMatrix, Eqn and matrix2latex" author: Phil Chalmers, John Fox, Michael Friendly date: "`r Sys.Date()`" output: - pdf_document: - toc: true - keep_tex: true bookdown::html_document2: base_format: rmarkdown::html_vignette number_sections: false @@ -17,6 +14,12 @@ vignette: > %\VignetteEngine{knitr::rmarkdown} --- + + ```{r nomessages, echo = FALSE} knitr::opts_chunk$set( warning = FALSE,