Skip to content

Commit 448d78e

Browse files
committed
Fix coding style for brewer scales
Add spaces around `=`
1 parent d24a581 commit 448d78e

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

R/scale-brewer.r

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@
2020
#' @export
2121
#' @examples
2222
#' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
23-
#' (d <- qplot(carat, price, data=dsamp, colour=clarity))
23+
#' (d <- qplot(carat, price, data = dsamp, colour = clarity))
2424
#'
2525
#' # Change scale label
2626
#' d + scale_colour_brewer()
2727
#' d + scale_colour_brewer("clarity")
2828
#' d + scale_colour_brewer(expression(clarity[beta]))
2929
#'
3030
#' # Select brewer palette to use, see ?scales::brewer_pal for more details
31-
#' d + scale_colour_brewer(type="seq")
32-
#' d + scale_colour_brewer(type="seq", palette=3)
31+
#' d + scale_colour_brewer(type = "seq")
32+
#' d + scale_colour_brewer(type = "seq", palette = 3)
3333
#'
34-
#' d + scale_colour_brewer(palette="Blues")
35-
#' d + scale_colour_brewer(palette="Set1")
34+
#' d + scale_colour_brewer(palette = "Blues")
35+
#' d + scale_colour_brewer(palette = "Set1")
3636
#'
3737
#' # scale_fill_brewer works just the same as
3838
#' # scale_colour_brewer but for fill colours
39-
#' ggplot(diamonds, aes(x=price, fill=cut)) +
40-
#' geom_histogram(position="dodge", binwidth=1000) +
39+
#' ggplot(diamonds, aes(x = price, fill = cut)) +
40+
#' geom_histogram(position = "dodge", binwidth = 1000) +
4141
#' scale_fill_brewer()
4242
#'
4343
#' # Generate map data
@@ -46,14 +46,14 @@
4646
#' names(volcano3d) <- c("x", "y", "z")
4747
#'
4848
#' # Basic plot
49-
#' v <- ggplot() + geom_tile(aes(x=x, y=y, fill=z), data=volcano3d)
49+
#' v <- ggplot() + geom_tile(aes(x = x, y = y, fill = z), data = volcano3d)
5050
#' v
5151
#' v + scale_fill_distiller()
52-
#' v + scale_fill_distiller(palette=2)
53-
#' v + scale_fill_distiller(type="div")
54-
#' v + scale_fill_distiller(palette="Spectral")
55-
#' v + scale_fill_distiller(palette="Spectral", trans="reverse")
56-
#' v + scale_fill_distiller(type="qual")
52+
#' v + scale_fill_distiller(palette = 2)
53+
#' v + scale_fill_distiller(type = "div")
54+
#' v + scale_fill_distiller(palette = "Spectral")
55+
#' v + scale_fill_distiller(palette = "Spectral", trans = "reverse")
56+
#' v + scale_fill_distiller(type = "qual")
5757
#' # Not appropriate for continuous data, issues a warning
5858
scale_colour_brewer <- function(..., type = "seq", palette = 1) {
5959
discrete_scale("colour", "brewer", brewer_pal(type, palette), ...)
@@ -71,7 +71,7 @@ scale_colour_distiller <- function(..., type = "seq", palette = 1, values = NULL
7171
# warn about using a qualitative brewer palette to generate the gradient
7272
type <- match.arg(type, c("seq", "div", "qual"))
7373
if (type == "qual") {
74-
warning("Using a discrete colour palette in a continuous scale.\n Consider using type=\"seq\" or type=\"div\" instead")
74+
warning("Using a discrete colour palette in a continuous scale.\n Consider using type = \"seq\" or type = \"div\" instead")
7575
}
7676
continuous_scale("colour", "distiller",
7777
gradient_n_pal(brewer_pal(type, palette)(6), values, space), na.value = na.value, ...)
@@ -83,14 +83,14 @@ scale_colour_distiller <- function(..., type = "seq", palette = 1, values = NULL
8383
scale_fill_distiller <- function(..., type = "seq", palette = 1, values = NULL, space = "Lab", na.value = "grey50") {
8484
type <- match.arg(type, c("seq", "div", "qual"))
8585
if (type == "qual") {
86-
warning("Using a discrete colour palette in a continuous scale.\n Consider using type=\"seq\" or type=\"div\" instead")
86+
warning("Using a discrete colour palette in a continuous scale.\n Consider using type = \"seq\" or type = \"div\" instead")
8787
}
8888
continuous_scale("fill", "distiller",
8989
gradient_n_pal(brewer_pal(type, palette)(6), values, space), na.value = na.value, ...)
9090
}
9191

9292
# icon.brewer <- function() {
93-
# rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
94-
# gp=gpar(fill=RColorBrewer::brewer.pal(5, "PuOr"), col=NA)
93+
# rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width = 0.21,
94+
# gp = gpar(fill = RColorBrewer::brewer.pal(5, "PuOr"), col = NA)
9595
# )
9696
# }

man/scale_brewer.Rd

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@ See \url{http://colorbrewer2.org} for more information.
5353
}
5454
\examples{
5555
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
56-
(d <- qplot(carat, price, data=dsamp, colour=clarity))
56+
(d <- qplot(carat, price, data = dsamp, colour = clarity))
5757

5858
# Change scale label
5959
d + scale_colour_brewer()
6060
d + scale_colour_brewer("clarity")
6161
d + scale_colour_brewer(expression(clarity[beta]))
6262

6363
# Select brewer palette to use, see ?scales::brewer_pal for more details
64-
d + scale_colour_brewer(type="seq")
65-
d + scale_colour_brewer(type="seq", palette=3)
64+
d + scale_colour_brewer(type = "seq")
65+
d + scale_colour_brewer(type = "seq", palette = 3)
6666

67-
d + scale_colour_brewer(palette="Blues")
68-
d + scale_colour_brewer(palette="Set1")
67+
d + scale_colour_brewer(palette = "Blues")
68+
d + scale_colour_brewer(palette = "Set1")
6969

7070
# scale_fill_brewer works just the same as
7171
# scale_colour_brewer but for fill colours
72-
ggplot(diamonds, aes(x=price, fill=cut)) +
73-
geom_histogram(position="dodge", binwidth=1000) +
72+
ggplot(diamonds, aes(x = price, fill = cut)) +
73+
geom_histogram(position = "dodge", binwidth = 1000) +
7474
scale_fill_brewer()
7575

7676
# Generate map data
@@ -79,14 +79,14 @@ volcano3d <- melt(volcano)
7979
names(volcano3d) <- c("x", "y", "z")
8080

8181
# Basic plot
82-
v <- ggplot() + geom_tile(aes(x=x, y=y, fill=z), data=volcano3d)
82+
v <- ggplot() + geom_tile(aes(x = x, y = y, fill = z), data = volcano3d)
8383
v
8484
v + scale_fill_distiller()
85-
v + scale_fill_distiller(palette=2)
86-
v + scale_fill_distiller(type="div")
87-
v + scale_fill_distiller(palette="Spectral")
88-
v + scale_fill_distiller(palette="Spectral", trans="reverse")
89-
v + scale_fill_distiller(type="qual")
85+
v + scale_fill_distiller(palette = 2)
86+
v + scale_fill_distiller(type = "div")
87+
v + scale_fill_distiller(palette = "Spectral")
88+
v + scale_fill_distiller(palette = "Spectral", trans = "reverse")
89+
v + scale_fill_distiller(type = "qual")
9090
# Not appropriate for continuous data, issues a warning
9191
}
9292
\seealso{

0 commit comments

Comments
 (0)