color
and color2
aesthetics (scale_color_colorplane
) or
the fill
and fill2
aesthetics (scale_fill_colorplane
).
Variables mapped to color
or fill
are be mapped to the
horizontal component of the colorplane scale and color
/fill2
are mapped to the vertical component.
scale_color_colorplane(name = waiver(), axis_title = waiver(), axis_title_y = waiver(), breaks = waiver(), breaks_y = waiver(), labels = waiver(), labels_y = waiver(), limits = NULL, limits_y = NULL, color_projection = "YUV", rescaler = rescale, oob = censor, trans = "identity", na.color = "black", na.value = NA_real_, guide = "colorplane", ...)
scale_fill_colorplane(name = waiver(), axis_title = waiver(), axis_title_y = waiver(), breaks = waiver(), breaks_y = waiver(), labels = waiver(), labels_y = waiver(), limits = NULL, limits_y = NULL, color_projection = "YUV", rescaler = rescale, oob = censor, trans = "identity", na.color = "black", na.value = NA_real_, guide = "colorplane", ...)
NULL
, the title is not shown. By default (waiver),
the name of the scale or the name of the variable mapped to the aesthetic.NULL
for no breaks
waiver()
for the default breaks computed by the
transformation object
breaks
, but for vertical axis (i.e. color2
or fill2
)NULL
for no labels
waiver()
for the default labels computed by the
transformation object
breaks
)
labels
, but for vertical axis (i.e. color2
or fill2
)NA
to refer to the existing minimum or maximum.limits
, but for vertical axis (i.e. color2
or fill2
)color_projections
.scale_colour_gradient2
, scale_colour_gradientn
).
A function used to scale the input values to the range [0, 1]. A transformation object bundles together a transform, it's inverse,
and methods for generating breaks and labels. Transformation objects
are defined in the scales package, and are called name_trans
, e.g.
boxcox_trans
. You can create your own
transformation with trans_new
.
guide_colorplane
designed for this scale. Behavior of other
guides with this scale is not defined.color_projection
function.The YUV projection colorplane scale is visually divided into four quadrants: green when both values are small, fuchsia when both are large, orange when the horizontal variable is small and the vertical is large, and blue when the horizontal variable is large and the vertical is small. Values closer to the extremes are saturated and the center of the scale, representing the mid-point of the ranges for both variables, is grey.
Alternative color projections can be used, but may not be as interpretable.
See color_projections
for information on specifying or creating
other color projections.
continuous_scale
, modified 2016.
library(ggplot2)
if(requireNamespace("mapproj")) {
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()
}
# setting upper limit for qsec causes points for higher values to plot
# as na.color (black)
ggplot(mtcars, aes(x = wt, y = mpg, color = qsec, colour2 = hp)) +
geom_point(size = 4) +
scale_color_colorplane(limits = c(NA, 18.9))
Run the code above in your browser using DataLab