This function takes a ggplot object and source data frame, d, and adds manual color and fill scale layers based on cby and clr and/or faceting based on fby and scales. The data frame, d, is passed for determining the levels of the factor cby in d. The cby and fby columns in d must be factors. Like coloring, faceting must be done by a single factor variable, not crossed factors.

colorFacet(g, d, cby, clr, fby, scales)

Arguments

g

a ggplot object.

d

a data frame.

cby

character, factor column in d.

clr

character, color vector. If NULL, no coloring by levels of cby occurs.

fby

character, factor column in d.

scales

character, passed to scales in ggplot2::facet_wrap.

Value

a ggplot object.

Examples

#not run