Skip to content

Commit 1306d70

Browse files
audreyyeoCHgithub-actions[bot]dependabot-preview[bot]danielinteractive
authored
98 design doc plot bounds (#144)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Daniel Sabanes Bove <danielinteractive@users.noreply.github.com>
1 parent a0c19aa commit 1306d70

File tree

4 files changed

+431
-44
lines changed

4 files changed

+431
-44
lines changed

R/plotBounds.R

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,18 @@
2727
#' @example examples/plotBounds.R
2828
#' @export
2929
#' @keywords graphics
30-
plotBounds <- function(z, area = TRUE, grid = TRUE, yt = "x", add = FALSE,
31-
cols = c("green", "red", "darkgreen", "orange"),
32-
lwds = c(3, 3), ltype = "l", lpch = 16, lcex = 1, gy = 20) {
30+
plotBounds <- function(
31+
z,
32+
area = TRUE,
33+
grid = TRUE,
34+
yt = "x",
35+
add = FALSE,
36+
cols = c("green", "red", "darkgreen", "orange"),
37+
lwds = c(3, 3),
38+
ltype = "l",
39+
lpch = 16,
40+
lcex = 1,
41+
gy = 20) {
3342
n <- nrow(z)
3443
nmin <- min(z$looks)
3544
nmax <- max(z$looks)
@@ -51,40 +60,71 @@ plotBounds <- function(z, area = TRUE, grid = TRUE, yt = "x", add = FALSE,
5160
stop("yt can only be x or p")
5261
}
5362
if (add) {
54-
graphics::lines(z$looks, z2,
55-
lwd = lwds[1], col = cols[3], type = ltype,
56-
pch = lpch, cex = lcex
63+
graphics::lines(
64+
z$looks,
65+
z2,
66+
lwd = lwds[1],
67+
col = cols[3],
68+
type = ltype,
69+
pch = lpch,
70+
cex = lcex
5771
)
58-
graphics::lines(z$looks, z1,
59-
lwd = lwds[2], col = cols[4], type = ltype,
60-
pch = lpch, cex = lcex
72+
graphics::lines(
73+
z$looks,
74+
z1,
75+
lwd = lwds[2],
76+
col = cols[4],
77+
type = ltype,
78+
pch = lpch,
79+
cex = lcex
6180
)
6281
return(invisible())
6382
}
64-
graphics::plot(z$looks, rep(0, n),
65-
xlim = c(0, max(z$looks)), ylim = c(0, yU), type = "n",
66-
xlab = "n", ylab = ylabel
83+
graphics::plot(
84+
z$looks,
85+
rep(0, n),
86+
xlim = c(0, max(z$looks)),
87+
ylim = c(0, yU),
88+
type = "n",
89+
xlab = "n",
90+
ylab = ylabel
6791
)
6892
if (grid) {
6993
graphics::abline(h = gridy, col = "gray")
7094
}
7195
if (area) {
72-
graphics::polygon(c(z$looks, nmax, nmin), c(z2, yU, yU2),
96+
graphics::polygon(
97+
c(z$looks, nmax, nmin),
98+
c(z2, yU, yU2),
7399
lwd = lwds[1],
74-
col = cols[1], border = cols[1]
100+
col = cols[1],
101+
border = cols[1]
75102
)
76-
graphics::polygon(c(z$looks, nmax, nmin), c(z1, 0, 0),
103+
graphics::polygon(
104+
c(z$looks, nmax, nmin),
105+
c(z1, 0, 0),
77106
lwd = lwds[2],
78-
col = cols[2], border = cols[2]
107+
col = cols[2],
108+
border = cols[2]
79109
)
80110
} else {
81-
graphics::lines(z$looks, z2,
82-
lwd = lwds[1], col = cols[1], type = ltype,
83-
pch = lpch, cex = lcex
111+
graphics::lines(
112+
z$looks,
113+
z2,
114+
lwd = lwds[1],
115+
col = cols[1],
116+
type = ltype,
117+
pch = lpch,
118+
cex = lcex
84119
)
85-
graphics::lines(z$looks, z1,
86-
lwd = lwds[2], col = cols[2], type = ltype,
87-
pch = lpch, cex = lcex
120+
graphics::lines(
121+
z$looks,
122+
z1,
123+
lwd = lwds[2],
124+
col = cols[2],
125+
type = ltype,
126+
pch = lpch,
127+
cex = lcex
88128
)
89129
}
90130
return(invisible())

0 commit comments

Comments
 (0)