Skip to contents

Appends 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.

Usage

apply_stat_annotations(fig, stat_result, y.min = NULL)

Arguments

fig

A plotly figure object.

stat_result

List with annotations, shapes, and y.max as returned by create_stat_annotations().

y.min

Numeric or NULL; minimum y-axis value. If NULL, the existing y-axis range is preserved.

Value

The modified plotly figure.

Author

Jared Andrews

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)