gg_scale_compare: Set scale of filling or color for comparison in plot of...

Description Usage Arguments See Also Examples

View source: R/fct_stats_plotly.R

Description

This is a wrapper of ggplot2::scale_fill_manual() and ggplot2::scale_color_manual() to set two colors for comparing series.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gg_scale_compare(
  type = c("fill", "color"),
  name = "",
  base_id = "Origin",
  compare_id = "Select",
  base_color = "seagreen",
  compare_color = "red",
  base_label = base_id,
  compare_label = compare_id
)

Arguments

type

A character of setting type, "fill" for ggplot2::scale_fill_manual, "color" for ggplot2::scale_color_manual().

name

A character of name to display in title of legend box.

base_id

A character of name for base series.

compare_id

A character of name for comparing series.

base_color

A character of color for base series.

compare_color

A character of color for comparing series.

base_label

A character of label for base series to display in legend. default is base_id.

compare_label

A character of label for comparing series to display in legend. default is compare_id.

See Also

Other stats_plotly: stats_plotly

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 

p <- ds_vars %>%
  ggplot(aes(x = ~QR)) +
  gg_scale_compare(
    type = "fill",
    base_id = "Origin", compare_id = "Select"
  ) +
  labs(y = NULL)

# Add original plot
p <- p +
  geom_histogram(
    aes(fill = "Origin"),
    color = NA
  )
# Add comparing plot
p <- p +
  geom_histogram(
    data = ds_vars_compare,
    aes(fill = "Select"), color = NA,
  )

## End(Not run)

chriszheng2016/zstexplorer documentation built on June 13, 2021, 9:47 a.m.