Apply statistical annotation shapes and annotations to a plotly figure
Source:R/stat_helper.R
apply_stat_annotations.RdAppends the shapes and annotations from create_stat_annotations() to
an existing plotly figure's layout. Adjusts the y-axis range to accommodate
the annotation brackets.
Arguments
- fig
A plotly figure object.
- stat_result
List with
annotations,shapes, andy.maxas returned bycreate_stat_annotations().- y.min
Numeric or NULL; minimum y-axis value. If NULL, the existing y-axis range is preserved.
Examples
stats_df <- compute_pairwise_stats(
df = example_iris,
x = "Species",
y = "Sepal.Length",
test = "wilcox.test"
)
fig <- plotly::plot_ly(
data = example_iris, x = ~Species, y = ~Sepal.Length, type = "box"
)
stat_result <- create_stat_annotations(
stats_df = stats_df,
fig = fig,
df = example_iris,
x = "Species",
y = "Sepal.Length",
display = "symbol"
)
apply_stat_annotations(fig, stat_result)