Skip to content

Commit b2a7789

Browse files
author
Kevin Cazelles
committed
add pkgdown website
1 parent 0f7e9ed commit b2a7789

192 files changed

Lines changed: 11355 additions & 427 deletions

File tree

Some content is hidden

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

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
^inst/tmp
1414
^LICENSE
1515
^CONDUCT.md
16+
^_pkgdown\.yml$
17+
^docs$

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: graphicsutils
22
Type: Package
33
Title: Collection of graphics utilities
44
Version: 1.2-0
5-
Date: 2018-03-18
5+
Date: 2018-07-27
66
Authors@R: c(person("Kevin", "Cazelles", role = c("aut", "cre"), email = "kcazelle@uoguelph.ca", comment = c(ORCID = "0000-0001-6619-9874")),
77
person("Nicolas", "Casajus", role = c("aut"), comment = c(ORCID = "0000-0002-5537-5294")),
88
person("David", "Beauchesne", role = c("aut")))

R/RcppExports.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Generated by using Rcpp::compileAttributes() -> do not edit by hand Generator
2-
# token: 10BE3573-1514-4C36-9D1C-5A225CD40393
1+
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
2+
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
33

44
pointsInPolygon_core <- function(points, polygon) {
5-
.Call("_graphicsutils_pointsInPolygon_core", PACKAGE = "graphicsutils", points,
6-
polygon)
5+
.Call('_graphicsutils_pointsInPolygon_core', PACKAGE = 'graphicsutils', points, polygon)
76
}
87

R/circles.R

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#' @param to the angles, expressed in radians, to which circles are drawn.
1010
#' @param incr increments between two points to be linked (expressed in radians).
1111
#' @param pie a logical. If \code{TRUE}, end points are linked with the center of the circle (default is set to \code{FALSE}).
12-
#' @param clockwise a logical. Shall slices be drawn clockwise?
12+
#' @param clockwise a logical. Shall circles and arcs be drawn clockwise? Defaut is `FALSE`.
1313
#' @param add a logical. Should the circles be added on the current plot?
1414
#' @param ... additional arguments to be passed to \code{\link[graphics]{polygon}} function.
1515
#'
@@ -47,12 +47,12 @@
4747
#' plot0(x=c(-2,2),y=c(-2,2), asp=1)
4848
#' circles(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)
4949

50-
circles <- function(x, y = x, radi = 1, from = 0, to = 2*pi, incr = 0.01, pie = FALSE,
50+
circles <- function(x, y = x, radi = 1, from = 0, to = 2 * pi, incr = 0.01, pie = FALSE,
5151
clockwise = FALSE, add = TRUE, ...) {
52-
#
53-
pipi <- 2*pi
54-
#
55-
if (!isTRUE(add))
52+
#
53+
pipi <- 2 * pi
54+
#
55+
if (!isTRUE(add))
5656
plot0()
5757
# format checking / adjusting vectors sizes
5858
matx <- as.matrix(x)
@@ -61,6 +61,7 @@ circles <- function(x, y = x, radi = 1, from = 0, to = 2*pi, incr = 0.01, pie =
6161
nbcol <- min(nbarg, ncol(matx))
6262
for (i in 1L:nbcol) assign(argn[i], matx[, i])
6363
argo <- list(x, y, radi, from, to)
64+
##
6465
sz <- max(sapply(argo, length))
6566
for (i in 1L:nbarg) assign(argn[i], rep_len(argo[[i]], sz))
6667
# drawing circles
@@ -71,27 +72,27 @@ circles <- function(x, y = x, radi = 1, from = 0, to = 2*pi, incr = 0.01, pie =
7172
## --- angles sequence
7273
if (dagl >= pipi) {
7374
# no point of drawing a circle multiple times
74-
to[i] <- pipi
75-
from[i] <- 0
75+
to[i] <- pipi + 0.5 * pi
76+
from[i] <- 0.5 * pi
7677
}
77-
##
78+
##
7879
if (!clockwise) {
79-
sqc <- seq(from[i], from[i] + dagl, by = incr)
80+
sqc <- seq(from[i], from[i] + dagl, by = incr)
8081
} else {
81-
sqc <- seq(from[i], from[i] -dagl, by = -incr)
82+
sqc <- seq(from[i], from[i] - dagl, by = -incr)
8283
}
83-
84+
##
8485
if (!pie) {
8586
xout <- x[i] + radi[i] * cos(sqc)
8687
yout <- y[i] + radi[i] * sin(sqc)
8788
} else {
8889
xout <- x[i] + c(0, radi[i] * cos(sqc), 0)
8990
yout <- y[i] + c(0, radi[i] * sin(sqc), 0)
9091
}
91-
92+
9293
graphics::polygon(xout, yout, ...)
9394
out[[i]] <- data.frame(x = xout, y = yout)
9495
}
95-
96+
9697
invisible(out)
9798
}

README.md

Lines changed: 2 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Related with this, is one very helpful article by Paul Murrell: [The
2121
gridGraphics
2222
Package](https://journal.r-project.org/archive/2015-1/murrell.pdf).
2323

24+
2425
Status
2526
------
2627

@@ -45,182 +46,10 @@ Then, load it:
4546

4647
library(graphicsutils)
4748

48-
Main features
49-
-------------
50-
51-
### Empty your plot
52-
53-
To start a figure from scratch it is often useful to get a plot without
54-
nothing but having the correct size of axes. `plot0()` allows the user
55-
to do so:
56-
57-
plot0(c(0,1),c(0,1))
58-
59-
![](inst/assets/img/plot0-1.png)
60-
61-
Quite empty, isn’t it? Also, it can be filled with any color using the
62-
`fill` parameter.
63-
64-
plot0(c(-10,10), fill='#ebebeb', grid.col = 'white')
65-
66-
![](inst/assets/img/plot0v2-1.png)
67-
68-
And also add a text:
69-
70-
plot0(c(-10,10), asp=1, fill=8, text='cool', srt=45, cex=4, col=2)
71-
72-
![](inst/assets/img/plot0v3-1.png)
73-
74-
### Add a box
75-
76-
The `box2()` function allows the user to add any axes around the plot in
77-
a more flexible way.
78-
79-
par(mar=rep(2,4))
80-
plot0()
81-
box2(which="figure", lwd=2, fill="grey30")
82-
box2(side=12, lwd=2, fill="grey80")
83-
axis(1)
84-
axis(2)
85-
86-
![](inst/assets/img/box2-1.png)
87-
88-
### Encircle points
89-
90-
coords <- cbind(runif(10), runif(10))
91-
plot0(coords)
92-
points(coords, bg="grey25", pch=21)
93-
encircle(coords, border="#7b11a1", lwd=2)
94-
95-
![](inst/assets/img/encircle-1.png)
96-
97-
### Add an image
98-
99-
The `pchImage()` function eases the uses of `rasterImage()` to add
100-
images (including png and jpeg files) on a graph. It allows to change
101-
the color of the whole image.
102-
103-
pathLogo <- system.file("img", "Rlogo.png", package="png")
104-
par(mar=c(4,1,4,1), mfrow=c(1,2))
105-
plot0()
106-
pchImage(0, 0, file=pathLogo, cex.x =4.5, cex.y=4)
107-
plot0()
108-
pchImage(0, 0, file=pathLogo, cex.x =4.5, cex.y=4, col="grey25", angle=25)
109-
110-
![](inst/assets/img/pchImage-1.png)
111-
112-
### A stacked areas chart
113-
114-
#### A simple stacked areas
115-
116-
plot0(c(0, 10),c(0, 10))
117-
sz <- 100
118-
seqx <- seq(0, 10, length.out=sz)
119-
seqy1 <- 0.2*seqx*runif(sz, 0, 1)
120-
seqy2 <- 4+0.25*seqx*runif(sz, 0, 1)
121-
seqy3 <- 8+0.25*seqx*runif(sz, 0, 1)
122-
envelop(seqx, seqy1, seqy2, col="grey85", border=NA)
123-
124-
![](inst/assets/img/envelop-1.png)
125-
126-
#### A complete stacked areas
12749

128-
x <- data.frame(matrix(runif(200, 2, 10), 8, 25))
129-
stackedAreas(x)
130-
131-
![](inst/assets/img/stackedArea-1.png)
132-
133-
### Polar plot
134-
135-
polarPlot(1:40, stats::runif(40), to=1.9*pi, col="grey30", border="grey80")
136-
137-
![](inst/assets/img/polarPlot-1.png)
138-
139-
### Get pretty ranges
140-
141-
vec <- stats::runif(20)
142-
range(vec)
143-
R>> [1] 0.05697909 0.95889704
144-
prettyRange(vec)
145-
R>> [1] 0.05 1.00
146-
prettyRange(c(3.85, 3.88245))
147-
R>> [1] 3.850 3.885
148-
149-
### Interactive functions
150-
151-
Some functions are interactive and fairly understandable! So, I suggest
152-
you try the following functions:
153-
154-
pickColors()
155-
156-
layout2()
157-
158-
### Colors
159-
160-
`darken()` and `lighten()` functions are convenient way to produce
161-
consistent set of shaded colors with minimal effort; also use
162-
`showPalette()` to display your palette.
163-
164-
someblue <- darken("blue", 10*1:9)
165-
showPalette(someblue)
166-
167-
![](inst/assets/img/darken-1.png)
168-
169-
somered <- lighten("red", 10*1:9)
170-
showPalette(somered, add_codecolor=TRUE)
171-
172-
![](inst/assets/img/lighten-1.png)
173-
174-
Since version 1.1-2 a set of color palettes has been added, see
175-
`gpuPalette()`.
176-
177-
showPalette(gpuPalette("insileco"), add_codecolor=TRUE)
178-
179-
![](inst/assets/img/insileco-1.png)
180-
181-
Image 2
182-
-------
183-
184-
image2(matrix(1:9, 3))
185-
186-
![](inst/assets/img/image2-1.png)
187-
188-
image2(matrix(1:27, 3), from=2, border = 2, lwd=2)
189-
190-
![](inst/assets/img/image2-2.png)
191-
192-
Vector fields
50+
Main features
19351
-------------
19452

195-
systLin <- function(X, beta){
196-
Y <- matrix(0,ncol=2)
197-
Y[1L] <- beta[1,1]*X[1L]+beta[1,2]*X[2L]
198-
Y[2L] <- beta[2,1]*X[1L]+beta[2,2]*X[2L]
199-
return(Y)
200-
}
201-
seqx <- seq(-2,2,0.31)
202-
seqy <- seq(-2,2,0.31)
203-
beta1 <- matrix(c(0,-1,1,0),2)
204-
# Plot 1:
205-
vecfield2d(coords=expand.grid(seqx, seqy), FUN=systLin, args=list(beta=beta1))
206-
207-
![](inst/assets/img/vectorfields-1.png)
208-
209-
# # Plot 2:
210-
graphics::par(mar=c(2,2,2,2))
211-
vecfield2d(coords=expand.grid(seqx, seqy), FUN=systLin,
212-
args=list(beta=beta1), cex.x=0.35, cex.arr=0.25,
213-
border=NA,cex.hh=1, cex.shr=0.6, col=8)
214-
graphics::abline(v=0, h=0)
215-
216-
![](inst/assets/img/vectorfields-2.png)
217-
218-
Compass Rose
219-
------------
220-
221-
compassRose(0, rot=25, cex.cr = 2, col.let =2, add = FALSE)
222-
223-
![](inst/assets/img/compassRose-1.png)
22453

22554
Code of Conduct
22655
---------------

_pkgdown.yml

Whitespace-only changes.

0 commit comments

Comments
 (0)