Description Usage Arguments Details References Examples
View source: R/guide_colorplane.R
Generates a guide to explain the colors plotted via
scale_color_colorplane
and scale_fill_colorplane
.
1 2 3 4 5 6 7 8 9 10 11 12 | guide_colorplane(title = waiver(), title.position = c("top", "bottom"),
title.theme = NULL, title.hjust = 0.5, title.vjust = NULL,
axis.title = waiver(), axis.title.position = c("bottom", "top"),
axis.title.theme = NULL, axis.title.hjust = NULL,
axis.title.vjust = NULL, axis.title.y = waiver(),
axis.title.y.position = c("left", "right"), axis.title.y.theme = NULL,
axis.title.y.hjust = NULL, axis.title.y.vjust = NULL, label = TRUE,
label.position = c("bottom", "top"), label.theme = NULL,
label.hjust = NULL, label.vjust = NULL, label.y.position = c("left",
"right"), label.y.theme = NULL, label.y.hjust = NULL,
label.y.vjust = NULL, planewidth = NULL, planeheight = NULL,
nbin = 20, ticks = TRUE, default.unit = "line", order = 0, ...)
|
title |
A character string or expression indicating a title of guide.
If |
title.position |
Character string indicating position for the main title. One of "top" (default) or "bottom". |
title.theme |
A theme object for rendering the title text. Usually the
object of |
title.hjust |
A number specifying horizontal justification of the title text. |
title.vjust |
A number specifying vertical justification of the title text. |
axis.title, axis.title.y |
Character strings or expressions indicating
the horizontal and vertical axis titles in the guide, respectively. If
|
axis.title.position, axis.title.y.position |
Character vectors indicating
the position(s) of axis titles. |
axis.title.theme, axis.title.y.theme |
Theme objects for rendering the
axis title text. Typically an |
axis.title.hjust, axis.title.vjust, axis.title.y.vjust, axis.title.y.hjust |
Numerics specifying the horizontal ( |
label |
logical. If |
label.position, label.y.position |
Character vectors indicating the
position(s) of axis labels. For |
label.theme, label.y.theme |
Theme objects for rendering axis label text.
Usually the object of |
label.hjust, label.vjust, label.y.hjust, label.y.vjust |
Numerics
specifying the horizontal ( |
planewidth, planeheight |
Numeric or |
nbin |
Number specifying how many color pixels are generated for each dimension of the colorplane. Higher numbers increase guide color accuracy (especially for larger sized guides) at the expense of speed. |
ticks |
A logical specifying if tick marks on colorbar should be visible. |
default.unit |
A character string indicating unit for |
order |
positive integer less that 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. |
... |
ignored. |
The guide is based on guide_colorbar
, but extended to
be a plane of colors with ticks and labels for both variables in the scale.
All *.theme
arguments accept two types of arguments: a complete theme
object (e.g. the object returned by theme_grey
) or an
element_text
. If a theme is given, the related element
will be extracted from the theme and used as-is. If an element is given, any
missing parameters will be inherited from the plot's theme before use. If not
specified, *.hjust
and *.vjust
parameters will draw from the
corresponding *.theme
argument, the plot's theme, or a default of 0.5
(centered). One exception is title.hjust
which has been given a
default value of 0.5 to override a undesirable default value in the default
ggplot theme. Specify title.hjust = NULL
to restore normal inheritance
if needed.
Based on guide_colorbar
, modified 2016.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | if(requireNamespace("mapproj")) {
library(ggplot2)
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
states_map <- map_data("state")
ggplot(crimes,
aes(map_id = state, fill = Murder, fill2 = UrbanPop)) +
geom_map(map = states_map) +
scale_fill_colorplane() +
expand_limits(x = states_map$long, y = states_map$lat) +
coord_map() +
guides(fill = guide_colorplane("My Title", axis.title = "Murder Rate",
axis.title.y = "Urban Population %", label.position = c("top", "bottom"),
label.y.position = c("left", "right")))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.