scale_color_colorplane
and scale_fill_colorplane
.
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, ...)
element_text
is expected. By default, the theme is
specified by legend.title
in theme
or theme.NULL
, the title is not shown. By default (waiver),
the name of the scale or the name of the variable mapped to the aesthetic.axis.title.position
: "top" and/or
"bottom" (default). axis.title.y.position
: "left" (default) and/or
"right".element_text
object.
When NULL
, defaults to settings for axis.title.x
and
axis.title.y
in the plot theme.hjust
) and vertical
(vjust
) justifications of the horizontal (axis.title
) and
vertical (axis.title.y
) axis title text.TRUE
then the labels are drawn. If
FALSE
then the labels are invisible.label.position
, "top" and/or
"bottom" (default). For label.y.position
, "left" (default) and/or
"right".element_text
is expected. By
default, the theme is specified by axis.text.*
in the plot theme.hjust
) and vertical (vjust
)
justifications of the horizontal (label
) and vertical
(label.y
) axis label text.unit
objects
specifying the width and height of the colorplane. Default values are 5
times the legend.key.width/height
or legend.key.size
in the
plot theme.planewidth
and planeheight
.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.
guide_colorbar
, modified 2016.
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")))
}
Run the code above in your browser using DataLab