Skip to contents

Replace the stratum level names with a color symbol in the risk tables. Use this function when stratum level names are long.

Usage

add_risktable_strata_symbol(
  symbol = NULL,
  size = 15,
  face = "bold",
  vjust = 0.3,
  ...
)

Arguments

symbol

UTF-8 code of shape to replace strata level with. Default is a rectangle ("\U25AC"). Other common options are circle ("\U25CF") and diamond ("\U25C6"). While a symbol is the most common string to pass here, any string is acceptable.

size, face, vjust, ...

arguments passed to a function similar to ggtext::element_markdown()

Value

a ggplot2 figure

See also

Visit the gallery for examples modifying the default figures

Examples

p <-
  survfit2(Surv(time, status) ~ sex, data = df_lung) %>%
  ggsurvfit(linewidth = 1) +
  add_confidence_interval() +
  add_risktable(risktable_group = "risktable_stats") +
  scale_ggsurvfit()

 p + add_risktable_strata_symbol()
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?

 p + add_risktable_strata_symbol(symbol = "\U25CF", size = 10)
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?
#> Warning: All aesthetics have length 1, but the data has 208 rows.
#>  Did you mean to use `annotate()`?