-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathguide_colourstrip.Rd
150 lines (136 loc) · 4.45 KB
/
guide_colourstrip.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/guide_colorstrip.R
\name{guide_colourstrip}
\alias{guide_colourstrip}
\alias{guide_train.colorstrip}
\alias{guide_geom.colorstrip}
\alias{guide_colorstrip}
\alias{guide_gengrob.colorstrip}
\title{Discretized continuous colour guide}
\usage{
guide_colourstrip(
title = ggplot2::waiver(),
title.position = NULL,
title.theme = NULL,
title.hjust = NULL,
title.vjust = NULL,
label = TRUE,
label.position = NULL,
label.theme = NULL,
label.hjust = NULL,
label.vjust = NULL,
barwidth = NULL,
barheight = NULL,
ticks = FALSE,
draw.ulim = TRUE,
draw.llim = TRUE,
inside = FALSE,
direction = NULL,
default.unit = "line",
reverse = FALSE,
order = 0,
available_aes = c("colour", "color", "fill"),
...
)
guide_colorstrip(
title = ggplot2::waiver(),
title.position = NULL,
title.theme = NULL,
title.hjust = NULL,
title.vjust = NULL,
label = TRUE,
label.position = NULL,
label.theme = NULL,
label.hjust = NULL,
label.vjust = NULL,
barwidth = NULL,
barheight = NULL,
ticks = FALSE,
draw.ulim = TRUE,
draw.llim = TRUE,
inside = FALSE,
direction = NULL,
default.unit = "line",
reverse = FALSE,
order = 0,
available_aes = c("colour", "color", "fill"),
...
)
}
\arguments{
\item{title}{A character string or expression indicating a title of guide.
If \code{NULL}, the title is not shown. By default
(\code{\link[ggplot2:waiver]{waiver()}}), the name of the scale object or the name
specified in \code{\link[ggplot2:labs]{labs()}} is used for the title.}
\item{draw.ulim}{A logical specifying if the upper limit tick marks should
be visible.}
\item{draw.llim}{A logical specifying if the lower limit tick marks should
be visible.}
\item{inside}{logical indicating where to position labels (see examples).}
\item{direction}{A character string indicating the direction of the guide.
One of "horizontal" or "vertical."}
\item{reverse}{logical. If \code{TRUE} the colourbar is reversed. By default,
the highest value is on the top and the lowest value is on the bottom}
\item{order}{positive integer less than 99 that specifies the order of
this guide among multiple guides. This controls the order in which
multiple guides are displayed, not the contents of the guide itself.
If 0 (default), the order is determined by a secret algorithm.}
\item{available_aes}{A vector of character strings listing the aesthetics
for which a colourbar can be drawn.}
\item{...}{ignored.}
\item{theme}{A \code{\link[ggplot2:theme]{theme}} object to style the guide individually or
differently from the plot's theme settings. The \code{theme} argument in the
guide overrides, and is combined with, the plot's theme.}
}
\value{
A guide object.
}
\description{
A version of \link[ggplot2:guide_colourbar]{ggplot2::guide_colourbar} that displays discretized values and,
by default, puts labels in between values.
}
\details{
The default behaviour works fell for geom_contour_fill in which the colours
represent the value between contour surfaces.
`inside = TRUE`` works better for geom_tile where the colour represents
the value of the data and is very similar to \link[ggplot2:guide_legend]{ggplot2::guide_legend}.
}
\examples{
# In this example the lowest colour represents an area of the data with values
# between 80 and 100.
library(ggplot2)
binwidth <- 20
data(volcano)
ggplot(reshape2::melt(volcano), aes(Var1, Var2, z = value)) +
geom_contour_fill(binwidth = binwidth) +
scale_fill_continuous(guide = guide_colourstrip(),
breaks = MakeBreaks(binwidth))
# Difference between guide_legend() and guide_colorbar2(inside = T)
df <- reshape2::melt(outer(1:4, 1:4), varnames = c("X1", "X2"))
g <- ggplot(df, aes(X1, X2)) +
geom_tile(aes(fill = value)) +
theme(legend.position = "bottom")
# Tick labels are to the side
g + scale_fill_continuous(guide = guide_legend())
# Tick labels are at the bottom
g + scale_fill_continuous(guide = guide_colourstrip(inside = TRUE))
}
\seealso{
Other ggplot2 helpers:
\code{\link{MakeBreaks}()},
\code{\link{WrapCircular}()},
\code{\link{geom_arrow}()},
\code{\link{geom_contour2}()},
\code{\link{geom_contour_fill}()},
\code{\link{geom_label_contour}()},
\code{\link{geom_relief}()},
\code{\link{geom_streamline}()},
\code{\link{map_labels}},
\code{\link{reverselog_trans}()},
\code{\link{scale_divergent}},
\code{\link{scale_longitude}},
\code{\link{stat_na}()},
\code{\link{stat_subset}()}
}
\concept{ggplot2 helpers}
\keyword{internal}