Skip to content

Commit ea50064

Browse files
author
Kevin Cazelles
committed
revision => vignette + documentation 📝
1 parent 4afc1c5 commit ea50064

101 files changed

Lines changed: 768 additions & 666 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ importFrom(graphics,points)
6161
importFrom(graphics,rect)
6262
importFrom(graphics,text)
6363
importFrom(magrittr,"%<>%")
64-
importFrom(magrittr,"%>%")
6564
importFrom(stats,aggregate)
6665
importFrom(stats,quantile)
6766
importFrom(stats,rnorm)

R/arrows2.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' Add arrows to a plot.
22
#'
3-
#' Draw arrows between pairs of points. Arrows drawn are fully customizable by using parameters of `polygon` function.
3+
#' Draw a custom arrows between pairs of points.
44
#'
55
#' @export
66
#'
@@ -14,7 +14,7 @@
1414
#' @param cex.shr the magnification coefficient to be used to change the height of arrows towards their heads.
1515
#' @param cex.hl the magnification coefficient to be used for the lengths of arrows' head.
1616
#' @param cex.hh the magnification coefficient to be used for the heights of arrows' head.
17-
#' @param prophead logical. If TRUE arrows are drawn with head proportionnal to the length of the arrows.
17+
#' @param prophead logical. If TRUE arrows are drawn with head proportional to the length of the arrows.
1818
#' @param twoheaded logical. If TRUE two-headed arrows are drawn, default is FALSE.
1919
#' @param ... additional arguments to be passed to `polygon` function.
2020
#'
@@ -35,10 +35,10 @@
3535
#' arrows2(runif(2), runif(2), x1=runif(2), y1=runif(2), prophead=FALSE, lty=3)
3636

3737

38-
arrows2 <- function(x0, y0, x1 = x0, y1 = y0, off0 = 0, off1 = off0, cex.arr = 1,
38+
arrows2 <- function(x0, y0, x1 = x0, y1 = y0, off0 = 0, off1 = off0, cex.arr = 1,
3939
cex.shr = 1, cex.hh = 1, cex.hl = 1, prophead = TRUE, twoheaded = FALSE, ...) {
4040
stopifnot(all(c(off0, off1)^2 < 1))
41-
## ---- Format checkings / adjusting vectors sizes
41+
## ---- Format checking / adjusting vectors sizes
4242
argn <- c("x0", "y0", "x1", "y1")
4343
argo <- list(x0, y0, x1, y1)
4444
sz <- max(sapply(list(x0, y0, x1, y1), length))
@@ -48,7 +48,7 @@ arrows2 <- function(x0, y0, x1 = x0, y1 = y0, off0 = 0, off1 = off0, cex.arr = 1
4848
rx <- (x1 - x0)
4949
ry <- (y1 - y0)
5050
distpt <- sqrt(rx * rx + ry * ry)
51-
# ----- Checkings
51+
# ----- Checking
5252
pb <- which(distpt == 0)
5353
if (length(pb) > 0) {
5454
warning("Zero-length arrows are skipped.")
@@ -84,15 +84,16 @@ arrows2 <- function(x0, y0, x1 = x0, y1 = y0, off0 = 0, off1 = off0, cex.arr = 1
8484
sqptx <- rep(x0[i], 7) + c(0, lg2, lg2, lg1, lg2, lg2, 0)
8585
sqpty <- rep(y0[i], 7) + c(hg1, hg2, hg3, 0, -hg3, -hg2, -hg1)
8686
} else {
87-
sqptx <- rep(x0[i], 12) + c(0, lg3, lg3, 0.5 * lg1, lg2, lg2, lg1, lg2,
87+
sqptx <- rep(x0[i], 12) + c(0, lg3, lg3, 0.5 * lg1, lg2, lg2, lg1, lg2,
8888
lg2, 0.5 * lg1, lg3, lg3)
89-
sqpty <- rep(y0[i], 12) + c(0, hg3, hg2, hg1, hg2, hg3, 0, -hg3, -hg2,
89+
sqpty <- rep(y0[i], 12) + c(0, hg3, hg2, hg1, hg2, hg3, 0, -hg3, -hg2,
9090
-hg1, -hg2, -hg3)
9191
}
9292
## ----
93-
ptcoord <- rotation(sqptx, sqpty, rot = anglept[i], xrot = x0[i], yrot = y0[i],
93+
ptcoord <- rotation(sqptx, sqpty, rot = anglept[i], xrot = x0[i], yrot = y0[i],
9494
rad = TRUE)
9595
graphics::polygon(ptcoord$x, ptcoord$y, ...)
9696
}
97+
## ----
9798
invisible(NULL)
9899
}

R/compassRose.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#' compassRose(0, rot=25, cex.cr = 2, col.let =2, add = FALSE)
2727

2828
#' @export
29-
#' @describeIn compassRose A compass rose with the four cardinal directions and additionnal directions.
29+
#' @describeIn compassRose A compass rose with the four cardinal directions and additional directions.
3030
compassRose <- function(x = 0, y = 0, labels = c("S", "W", "N", "E"), rot = 0, cex.cr = 1,
3131
cex.let = cex.cr, col.cr = c(1, 8), col.let = 1, border = c(1, 8), offset = 1.2,
3232
add = TRUE, ...) {

R/contrastColors.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
#'
1212
#' @details
1313
#' Based on the sum of colors' saturation \code{how_borw} returns black or white,
14-
#' \code{how_prop} proportially remove or add some saturation. \code{how_oppo}
14+
#' \code{how_prop} proportionally remove or add some saturation. \code{how_oppo}
1515
#' opposes the color (255-x) and \code{how_cent} centers the columns, i.e. remove
1616
#' or add 127.
1717
#'
1818
#' @seealso
1919
#' \link[grDevices]{col2rgb}
2020
#'
2121
#' @importFrom grDevices col2rgb
22-
#' @importFrom magrittr %>%
2322
#' @export
2423
#'
2524
#' @examples
@@ -30,20 +29,20 @@
3029

3130
#' @describeIn contrastColors Retuns a set of colors contrasted.
3231
contrastColors <- function(colors, how = "how_borw", alpha = FALSE) {
33-
out <- colors %>% col2rgb(alpha = alpha) %>% apply(2L, how) %>% apply(2L, intToHex)
32+
out <- apply(apply(col2rgb(colors, alpha = alpha), 2L, how), 2L, intToHex)
3433
paste0("#", out)
3534
}
3635

3736
#' @export
3837
#' @describeIn contrastColors Retuns the hexadecimal string associates to a given vector of colors.
3938
col2Hex <- function(colors, alpha = FALSE) {
40-
out <- colors %>% col2rgb(alpha = alpha) %>% apply(2L, intToHex)
39+
out <- apply(col2rgb(colors, alpha = alpha), 2L, intToHex)
4140
paste0("#", out)
4241
}
4342

4443
how_borw <- function(x) {
4544
out <- x
46-
if (sum(x[1L:3L]) > 382)
45+
if (sum(x[1L:3L]) > 382)
4746
out[1L:3L] <- 0 else out[1L:3L] <- 255
4847
out
4948
}

R/darken.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' Lighten or darken colors
22
#'
3-
#' Returns lightened or darkened colors, vetorized over `percentage`.
3+
#' Returns lightened or darkened colors, vectorised over `percentage`.
44
#' `ramp` is valid for any couple of colors. Functions `darken` and
55
#' `lightened` actually call `ramp` to darken and lighten a given color.
66
#'
@@ -21,7 +21,7 @@
2121
ramp <- function(fromcol, tocol, percentage = 50, as_rgb = FALSE) {
2222
perc <- as.integer(percentage)
2323
outcol <- (grDevices::colorRampPalette(c(fromcol, tocol)))(101)[perc + 1]
24-
if (as_rgb)
24+
if (as_rgb)
2525
outcol <- grDevices::col2rgb(outcol)
2626
return(outcol)
2727
}

R/donut.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#' @param add a logical. Should the donut chart be added on the current graph? If `FALSE` then a new plot is created.
1919
#' @param border the border color of the donut, set to `NA` which omits borders.
2020
#' @param clockwise a logical. Shall slices be drawn clockwise?
21-
#' @param ... additionnal arguments to be passed to lines methods.
21+
#' @param ... additional arguments to be passed to lines methods.
2222
#'
2323
#' @keywords donut
2424
#'

R/ellipse.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#' @details
2121
#' For a rotation angle of 0, major radii refer to the one along the x axis.
2222
#'
23-
#' The number of cicrles drawn is given by the maximum argument length amng `x`, `y`, `radi`, `from` and `to` arguments.
23+
#' The number of circles drawn is given by the maximum argument length among `x`, `y`, `radi`, `from` and `to` arguments.
2424
#' Sizes are adjusted using \code{\link{rep_len}} function.
2525
#'
2626
#' To plot ellipses, \code{\link{polygon}} function is called.
@@ -45,9 +45,9 @@
4545
#' plot0(x=c(-2,2),y=c(-2,2), asp=1)
4646
#' ellipse(x=c(-1,1),c(1,1,-1,-1),from=pi*seq(0.25,1,by=0.25),to=1.25*pi, col=2, border=4, lwd=3)
4747

48-
ellipse <- function(x = 0, y = x, mjradi = 1, mnradi = 0.5, from = 0, to = 2 * pi,
48+
ellipse <- function(x = 0, y = x, mjradi = 1, mnradi = 0.5, from = 0, to = 2 * pi,
4949
rot = 0, incr = 0.01, pie = FALSE, ...) {
50-
50+
5151
## --- format checking / adjusting vectors sizes
5252
matx <- as.matrix(x)
5353
argn <- c("x", "y", "mjradi", "mnradi", "from", "to")
@@ -57,22 +57,22 @@ ellipse <- function(x = 0, y = x, mjradi = 1, mnradi = 0.5, from = 0, to = 2 * p
5757
argo <- list(x, y, mjradi, mnradi, from, to)
5858
sz <- max(sapply(argo, length))
5959
for (i in 1L:nbarg) assign(argn[i], rep_len(argo[[i]], sz))
60-
60+
6161
## --- draw the ellipse
6262
for (i in 1L:sz) {
6363
## --- sequence to draw the ellipse
6464
if (abs(to[i] - from[i]) >= (2 * pi)) {
6565
to[i] <- 2 * pi
6666
from[i] <- 0
6767
} else {
68-
if ((to[i] > from[i]) & (to[i]%%(2 * pi) == 0))
68+
if ((to[i] > from[i]) & (to[i]%%(2 * pi) == 0))
6969
to[i] <- 2 * pi
7070
to[i] <- to[i]%%(2 * pi)
7171
from[i] <- from[i]%%(2 * pi)
72-
if (to[i] < from[i])
72+
if (to[i] < from[i])
7373
to[i] <- to[i] + 2 * pi
7474
}
75-
##
75+
##
7676
sqc <- seq(from[i], to[i], by = incr)
7777
seqx <- x[i] + mjradi[i] * cos(sqc)
7878
seqy <- y[i] + mnradi[i] * sin(sqc)
@@ -82,8 +82,8 @@ ellipse <- function(x = 0, y = x, mjradi = 1, mnradi = 0.5, from = 0, to = 2 * p
8282
}
8383
rotpt <- graphicsutils::rotation(seqx, seqy, xrot = x[i], yrot = y[i], rot = rot)
8484
graphics::polygon(rotpt$x, rotpt$y, ...)
85-
85+
8686
}
87-
##
87+
##
8888
invisible(NULL)
8989
}

R/encircle.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' @param x the x coordinates of a set of points. Alternatively, a
66
#' single argument `x` can be provided.
77
#' @param y the y coordinates of a set of points.
8-
#' @param nb.pt the nuber of points to ge generated around eah coordinates.
8+
#' @param nb.pt the number of points to be generated around each coordinates.
99
#' @param off.set the y coordinates of a set of points.
1010
#' @param ... further arguments to be passed to \code{[graphics::polygon()]} function.
1111
#'
@@ -32,11 +32,11 @@ encircle <- function(x, y = NULL, nb.pt = 20, off.set = 1, ...) {
3232
seqa <- seq(0, 2 * pi, length.out = nb.pt + 1)[-1L]
3333
seqx <- ofs * cos(seqa)
3434
seqy <- ofs * sin(seqa)
35-
##
36-
pts <- data.frame(x = rep(cfig$x, each = nb.pt) + rep(seqx, nrow(cfig)), y = rep(cfig$y,
35+
##
36+
pts <- data.frame(x = rep(cfig$x, each = nb.pt) + rep(seqx, nrow(cfig)), y = rep(cfig$y,
3737
each = nb.pt) + rep(seqy, nrow(cfig)))
3838
## compute the convex hull and plot it using user system
3939
graphics::polygon(toUser(pts[grDevices::chull(pts), ]), ...)
40-
##
40+
##
4141
invisible(NULL)
4242
}

R/envelop.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#' Compute the coordinates of an envelop.
22
#'
3-
#' `envelop` eases the compuation of the polygons described by to set
4-
#' of y coordinates along the x-axis. Optionnaly, the polygons could be added
3+
#' `envelop` eases the computation of the polygons described by to set
4+
#' of y coordinates along the x-axis. Optionally, the polygons could be added
55
#' on the current plot.
66
#'
77
#' @param x vectors containing the x coordinates.
88
#' @param upper the y coordinates of the upper values.
99
#' @param lower the y coordinates of the lower values.
1010
#' @param add a logical. If `TRUE` the envelop is drawn as a polygon (default behavior).
11-
#' @param ... additionnal arguments to be passed to \code{[graphics::polygon()]} function.
11+
#' @param ... additional arguments to be passed to \code{[graphics::polygon()]} function.
1212
#'
1313
#' @export
1414
#'
@@ -29,7 +29,7 @@ envelop <- function(x, upper, lower = rep(0, length(upper)), add = TRUE, ...) {
2929
stopifnot(length(x) == length(upper))
3030
stopifnot(length(x) == length(lower))
3131
out <- list(x = c(x, rev(x)), y = c(upper, rev(lower)))
32-
if (add)
32+
if (add)
3333
graphics::polygon(c(x, rev(x)), c(upper, rev(lower)), ...)
3434
invisible(out)
3535
}

R/gpuPalettes.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#' Complete list of graphisutils' color palettes
1+
#' Complete list of graphicsutils' color palettes
22
#'
3-
#' Color palettes of the graphisutils package.
3+
#' Color palettes of the graphicsutils package.
44
#'
55
#' @export
66

0 commit comments

Comments
 (0)