20
20
# ' @export
21
21
# ' @examples
22
22
# ' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
23
- # ' (d <- qplot(carat, price, data= dsamp, colour= clarity))
23
+ # ' (d <- qplot(carat, price, data = dsamp, colour = clarity))
24
24
# '
25
25
# ' # Change scale label
26
26
# ' d + scale_colour_brewer()
27
27
# ' d + scale_colour_brewer("clarity")
28
28
# ' d + scale_colour_brewer(expression(clarity[beta]))
29
29
# '
30
30
# ' # 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)
33
33
# '
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")
36
36
# '
37
37
# ' # scale_fill_brewer works just the same as
38
38
# ' # 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) +
41
41
# ' scale_fill_brewer()
42
42
# '
43
43
# ' # Generate map data
46
46
# ' names(volcano3d) <- c("x", "y", "z")
47
47
# '
48
48
# ' # 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)
50
50
# ' v
51
51
# ' 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")
57
57
# ' # Not appropriate for continuous data, issues a warning
58
58
scale_colour_brewer <- function (... , type = " seq" , palette = 1 ) {
59
59
discrete_scale(" colour" , " brewer" , brewer_pal(type , palette ), ... )
@@ -71,7 +71,7 @@ scale_colour_distiller <- function(..., type = "seq", palette = 1, values = NULL
71
71
# warn about using a qualitative brewer palette to generate the gradient
72
72
type <- match.arg(type , c(" seq" , " div" , " qual" ))
73
73
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" )
75
75
}
76
76
continuous_scale(" colour" , " distiller" ,
77
77
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
83
83
scale_fill_distiller <- function (... , type = " seq" , palette = 1 , values = NULL , space = " Lab" , na.value = " grey50" ) {
84
84
type <- match.arg(type , c(" seq" , " div" , " qual" ))
85
85
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" )
87
87
}
88
88
continuous_scale(" fill" , " distiller" ,
89
89
gradient_n_pal(brewer_pal(type , palette )(6 ), values , space ), na.value = na.value , ... )
90
90
}
91
91
92
92
# 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)
95
95
# )
96
96
# }
0 commit comments