Skip to content

Commit 0406725

Browse files
committed
Fix line widths
1 parent a0e9d1c commit 0406725

17 files changed

+75
-37
lines changed

R/aes-position.r

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,29 @@
2020
#' # generate sample data
2121
#' library(plyr)
2222
#' abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
23-
#' b <- ggplot(abc, aes(x = X1, ymin = "0%", lower = "25%", middle = "50%", upper = "75%", ymax = "100%"))
23+
#' b <- ggplot(abc, aes(x = X1, ymin = "0%", lower = "25%",
24+
#' middle = "50%", upper = "75%", ymax = "100%"))
2425
#' b + geom_boxplot(stat = "identity")
2526
#'
2627
#' # Using annotate
2728
#' p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
28-
#' p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25, fill = "dark grey", alpha = .5)
29+
#' p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25,
30+
#' fill = "dark grey", alpha = .5)
2931
#'
3032
#' # Geom_segment examples
3133
#' library(grid)
32-
#' p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
33-
#' p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15), arrow = arrow(length = unit(0.5, "cm")))
34-
#' p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
34+
#' p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25),
35+
#' arrow = arrow(length = unit(0.5, "cm")))
36+
#' p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15),
37+
#' arrow = arrow(length = unit(0.5, "cm")))
38+
#' p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
39+
#' arrow = arrow(length = unit(0.5, "cm")))
3540
#'
3641
#' # You can also use geom_segment to recreate plot(type = "h") :
3742
#' counts <- as.data.frame(table(x = rpois(100, 5)))
3843
#' counts$x <- as.numeric(as.character(counts$x))
3944
#' with(counts, plot(x, Freq, type = "h", lwd = 10))
4045
#'
41-
#' qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x, size = I(10))
46+
#' qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x,
47+
#' size = I(10))
4248
NULL

R/geom-boxplot.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
#' # Using precomputed statistics
9393
#' # generate sample data
9494
#' abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
95-
#' b <- ggplot(abc, aes(x = X1, ymin = `0%`, lower = `25%`, middle = `50%`, upper = `75%`, ymax = `100%`))
95+
#' b <- ggplot(abc, aes(x = X1, ymin = `0%`, lower = `25%`,
96+
#' middle = `50%`, upper = `75%`, ymax = `100%`))
9697
#' b + geom_boxplot(stat = "identity")
9798
#' b + geom_boxplot(stat = "identity") + coord_flip()
9899
#' b + geom_boxplot(aes(fill = X1), stat = "identity")

R/geom-linerange.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#' # Generate data: means and standard errors of means for prices
1515
#' # for each type of cut
1616
#' dmod <- lm(price ~ cut, data=diamonds)
17-
#' cuts <- data.frame(cut=unique(diamonds$cut), predict(dmod, data.frame(cut = unique(diamonds$cut)), se=TRUE)[c("fit","se.fit")])
17+
#' cuts <- data.frame(cut = unique(diamonds$cut),
18+
#' predict(dmod, data.frame(cut = unique(diamonds$cut)), se=TRUE)[c("fit","se.fit")])
1819
#'
1920
#' qplot(cut, fit, data=cuts)
2021
#' # With a bar chart, we are comparing lengths, so the y-axis is

R/geom-map.r

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ NULL
5050
#' crimesm <- melt(crimes, id = 1)
5151
#' if (require(maps)) {
5252
#' states_map <- map_data("state")
53-
#' ggplot(crimes, aes(map_id = state)) + geom_map(aes(fill = Murder), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat)
53+
#' ggplot(crimes, aes(map_id = state)) +
54+
#' geom_map(aes(fill = Murder), map = states_map) +
55+
#' expand_limits(x = states_map$long, y = states_map$lat)
56+
#'
5457
#' last_plot() + coord_map()
55-
#' ggplot(crimesm, aes(map_id = state)) + geom_map(aes(fill = value), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat) + facet_wrap( ~ variable)
58+
#' ggplot(crimesm, aes(map_id = state)) +
59+
#' geom_map(aes(fill = value), map = states_map) +
60+
#' expand_limits(x = states_map$long, y = states_map$lat) +
61+
#' facet_wrap( ~ variable)
5662
#' }
5763
geom_map <- function(mapping = NULL, data = NULL, map, stat = "identity", ...) {
5864

R/geom-segment.r

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#' @examples
1313
#' library(grid) # needed for arrow function
1414
#' p <- ggplot(seals, aes(x = long, y = lat))
15-
#' (p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat), arrow = arrow(length = unit(0.1,"cm"))))
15+
#' (p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat),
16+
#' arrow = arrow(length = unit(0.1,"cm"))))
1617
#'
1718
#' if (require("maps")) {
1819
#'
@@ -40,7 +41,8 @@
4041
#' b <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
4142
#' b + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25))
4243
#' b + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15))
43-
#' b + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
44+
#' b + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
45+
#' arrow = arrow(length = unit(0.5, "cm")))
4446
geom_segment <- function (mapping = NULL, data = NULL, stat = "identity",
4547
position = "identity", arrow = NULL, lineend = "butt", na.rm = FALSE, ...) {
4648

R/geom-tile.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
#' # You can manually set the colour of the tiles using
6666
#' # scale_manual
6767
#' col <- c("darkblue", "blue", "green", "orange", "red")
68-
#' qplot(x, y, fill=col[z], data=example, geom="tile", width=w, group=1) + scale_fill_identity(labels=letters[1:5], breaks=col)
68+
#' qplot(x, y, fill=col[z], data=example, geom="tile", width=w, group=1) +
69+
#' scale_fill_identity(labels=letters[1:5], breaks=col)
6970
#' }
7071
geom_tile <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
7172
GeomTile$new(mapping = mapping, data = data, stat = stat, position = position, ...)

R/guide-legend.r

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,5 @@ guide_gengrob.legend <- function(guide, theme) {
516516

517517
gt
518518
}
519+
520+
globalVariables(c("R", "key.row", "key.col", "label.row", "label.col"))

R/stat-function.r

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
#' # Or
3131
#' qplot(c(-5, 5), geom = "blank") + stat_function(fun = dnorm)
3232
#' # To specify a different mean or sd, use the args parameter to supply new values
33-
#' ggplot(data.frame(x = c(-5, 5)), aes(x)) + stat_function(fun = dnorm, args = list(mean = 2, sd = .5))
33+
#' ggplot(data.frame(x = c(-5, 5)), aes(x)) +
34+
#' stat_function(fun = dnorm, args = list(mean = 2, sd = .5))
3435
#'
3536
#' # Two functions on the same plot
3637
#' f <- ggplot(data.frame(x = c(0, 10)), aes(x))
37-
#' f + stat_function(fun = sin, colour = "red") + stat_function(fun = cos, colour = "blue")
38+
#' f + stat_function(fun = sin, colour = "red") +
39+
#' stat_function(fun = cos, colour = "blue")
3840
#'
3941
#' # Using a custom function
4042
#' test <- function(x) {x ^ 2 + x + 20}

man/aes_position.Rd

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,30 @@ se + geom_pointrange()
2828
# generate sample data
2929
library(plyr)
3030
abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
31-
b <- ggplot(abc, aes(x = X1, ymin = "0\%", lower = "25\%", middle = "50\%", upper = "75\%", ymax = "100\%"))
31+
b <- ggplot(abc, aes(x = X1, ymin = "0\%", lower = "25\%",
32+
middle = "50\%", upper = "75\%", ymax = "100\%"))
3233
b + geom_boxplot(stat = "identity")
3334

3435
# Using annotate
3536
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
36-
p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25, fill = "dark grey", alpha = .5)
37+
p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25,
38+
fill = "dark grey", alpha = .5)
3739

3840
# Geom_segment examples
3941
library(grid)
40-
p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
41-
p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15), arrow = arrow(length = unit(0.5, "cm")))
42-
p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
42+
p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25),
43+
arrow = arrow(length = unit(0.5, "cm")))
44+
p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15),
45+
arrow = arrow(length = unit(0.5, "cm")))
46+
p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
47+
arrow = arrow(length = unit(0.5, "cm")))
4348

4449
# You can also use geom_segment to recreate plot(type = "h") :
4550
counts <- as.data.frame(table(x = rpois(100, 5)))
4651
counts$x <- as.numeric(as.character(counts$x))
4752
with(counts, plot(x, Freq, type = "h", lwd = 10))
4853

49-
qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x, size = I(10))
54+
qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x,
55+
size = I(10))
5056
}
5157

man/geom_boxplot.Rd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ qplot(year, budget, data = movies, geom = "boxplot",
117117
# Using precomputed statistics
118118
# generate sample data
119119
abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
120-
b <- ggplot(abc, aes(x = X1, ymin = `0\%`, lower = `25\%`, middle = `50\%`, upper = `75\%`, ymax = `100\%`))
120+
b <- ggplot(abc, aes(x = X1, ymin = `0\%`, lower = `25\%`,
121+
middle = `50\%`, upper = `75\%`, ymax = `100\%`))
121122
b + geom_boxplot(stat = "identity")
122123
b + geom_boxplot(stat = "identity") + coord_flip()
123124
b + geom_boxplot(aes(fill = X1), stat = "identity")

man/geom_linerange.Rd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ An interval represented by a vertical line.
3535
# Generate data: means and standard errors of means for prices
3636
# for each type of cut
3737
dmod <- lm(price ~ cut, data=diamonds)
38-
cuts <- data.frame(cut=unique(diamonds$cut), predict(dmod, data.frame(cut = unique(diamonds$cut)), se=TRUE)[c("fit","se.fit")])
38+
cuts <- data.frame(cut = unique(diamonds$cut),
39+
predict(dmod, data.frame(cut = unique(diamonds$cut)), se=TRUE)[c("fit","se.fit")])
3940

4041
qplot(cut, fit, data=cuts)
4142
# With a bar chart, we are comparing lengths, so the y-axis is

man/geom_map.Rd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@ library(reshape2) # for melt
6868
crimesm <- melt(crimes, id = 1)
6969
if (require(maps)) {
7070
states_map <- map_data("state")
71-
ggplot(crimes, aes(map_id = state)) + geom_map(aes(fill = Murder), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat)
71+
ggplot(crimes, aes(map_id = state)) +
72+
geom_map(aes(fill = Murder), map = states_map) +
73+
expand_limits(x = states_map$long, y = states_map$lat)
74+
7275
last_plot() + coord_map()
73-
ggplot(crimesm, aes(map_id = state)) + geom_map(aes(fill = value), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat) + facet_wrap( ~ variable)
76+
ggplot(crimesm, aes(map_id = state)) +
77+
geom_map(aes(fill = value), map = states_map) +
78+
expand_limits(x = states_map$long, y = states_map$lat) +
79+
facet_wrap( ~ variable)
7480
}
7581
}
7682

man/geom_segment.Rd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ Single line segments.
4242
\examples{
4343
library(grid) # needed for arrow function
4444
p <- ggplot(seals, aes(x = long, y = lat))
45-
(p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat), arrow = arrow(length = unit(0.1,"cm"))))
45+
(p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat),
46+
arrow = arrow(length = unit(0.1,"cm"))))
4647

4748
if (require("maps")) {
4849

@@ -70,7 +71,8 @@ library(grid) # needed for arrow function
7071
b <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
7172
b + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25))
7273
b + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15))
73-
b + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
74+
b + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
75+
arrow = arrow(length = unit(0.5, "cm")))
7476
}
7577
\seealso{
7678
\code{\link{geom_path}} and \code{\link{geom_line}} for multi-

man/geom_tile.Rd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ qplot(x, y, fill=factor(z), data=example, geom="tile", width=w)
8989
# You can manually set the colour of the tiles using
9090
# scale_manual
9191
col <- c("darkblue", "blue", "green", "orange", "red")
92-
qplot(x, y, fill=col[z], data=example, geom="tile", width=w, group=1) + scale_fill_identity(labels=letters[1:5], breaks=col)
92+
qplot(x, y, fill=col[z], data=example, geom="tile", width=w, group=1) +
93+
scale_fill_identity(labels=letters[1:5], breaks=col)
9394
}
9495
}
9596

man/label_wrap_gen.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
label_wrap_gen(width = 25)
77
}
88
\arguments{
9-
\item{width}{integer, target column width for output.}
9+
\item{width}{integer, target column width for output.}
1010
}
1111
\description{
1212
Uses \code{\link[base]{strwrap}} for line wrapping.

man/labeller.Rd

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
labeller(..., keep.as.numeric = FALSE)
77
}
88
\arguments{
9-
\item{...}{Named arguments of the form
10-
\code{variable=values}, where \code{values} could be a
11-
vector or method.}
9+
\item{...}{Named arguments of the form \code{variable=values},
10+
where \code{values} could be a vector or method.}
1211

13-
\item{keep.as.numeric}{logical, default TRUE. When FALSE,
14-
converts numeric values supplied as margins to the facet
15-
to characters.}
12+
\item{keep.as.numeric}{logical, default TRUE. When FALSE, converts numeric
13+
values supplied as margins to the facet to characters.}
1614
}
1715
\value{
1816
Function to supply to

man/stat_function.Rd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ qplot(c(-5, 5), stat = "function", fun = dnorm, geom = "line")
6060
# Or
6161
qplot(c(-5, 5), geom = "blank") + stat_function(fun = dnorm)
6262
# To specify a different mean or sd, use the args parameter to supply new values
63-
ggplot(data.frame(x = c(-5, 5)), aes(x)) + stat_function(fun = dnorm, args = list(mean = 2, sd = .5))
63+
ggplot(data.frame(x = c(-5, 5)), aes(x)) +
64+
stat_function(fun = dnorm, args = list(mean = 2, sd = .5))
6465
6566
# Two functions on the same plot
6667
f <- ggplot(data.frame(x = c(0, 10)), aes(x))
67-
f + stat_function(fun = sin, colour = "red") + stat_function(fun = cos, colour = "blue")
68+
f + stat_function(fun = sin, colour = "red") +
69+
stat_function(fun = cos, colour = "blue")
6870
6971
# Using a custom function
7072
test <- function(x) {x ^ 2 + x + 20}

0 commit comments

Comments
 (0)