View source: R/ggplot_functions.R
| share_scales | R Documentation |
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_scales lets you send identical arguments to a list of ggplot functions you
specify.
share_scales(...)
... |
Unnamed arguments should be |
A list of the ggproto objects
df <- data.frame(
x<-rnorm(100),
f<-c(rep("Label1",50), rep("Label2",50))
)
l <- c(1,2,3,4,5,6)
df <- data.frame(x = rgamma(100, 2, 2),
y = factor(sample(l, size=100, replace = TRUE)))
ggplot(df, aes(x=x, y=y, size=y, color=y, fill=y, shape=y)) +
geom_point() +
# Zplyr function
share_scales(scale_color_discrete, scale_size_discrete,
scale_fill_discrete, scale_shape_discrete,
name="Legend Label!",
breaks=c(1,2,3,4,5,6),
labels=c("uno","dos","tres","catorce","FIVE","siiiiiix"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.