share_discrete_scales: (Deprecated!) Share arguments amongst multiple ggplot...

View source: R/ggplot_functions.R

share_discrete_scalesR Documentation

(Deprecated!) Share arguments amongst multiple ggplot functions

Description

DEPRECATED AS HELL, please use share_scales instead.
Often it is the case that one wishes to pass identical arguments to multiple functions in ggplot. For example, if one wants to scale both color and fill with the same breaks and legend names/labels.
The function share_discrete_scales lets you send identical arguments to a list of ggplot functions you specify. Note that you need to pipe the ggplot object into this function. If you don't put this function immediately after invoking ggplot(...), the preceding objects should be added to the ggplot object with %+% instead of +.

Usage

share_discrete_scales(gg_obj, geom_func_list, ...)

Arguments

gg_obj

The ggplot object

geom_func_list

A vector or list of ggplot functions, e.g., c(scale_color_discrete, scale_fill_discrete)

...

Whatever arguments you want passed to these functions

See Also

share_scales

Examples

## Not run: 
df <- data.frame(
   x=rnorm(100),
   f=c(rep("Label1",50), rep("Label2",50))
)

ggplot(df, aes(x = x, color=f, fill=f)) %+%
   geom_histogram() %>%
   share_discrete_scales(c(scale_color_discrete, scale_fill_discrete),
                         name="Legend Label!",
                         breaks=c("Label1","Label2"),
                         labels=c("NewName1","NewName2")) +
   xlab("Name")

## End(Not run)

burchill/zplyr documentation built on Feb. 2, 2023, 11:01 a.m.