@@ -11,7 +11,7 @@ vignette: >
1111
1212``` {r setup, include = FALSE}
1313library(knitr)
14- opts_chunk$set(collapse = TRUE, comment = "#>")
14+ opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 6 )
1515inbo_colours <- c("#282A72", "#EF972C")
1616```
1717
@@ -144,6 +144,31 @@ plot_ly(timeserie, x = ~year, y = ~index) |>
144144 add_vert_norm(sd = ~s, link = "log")
145145```
146146
147+ ## ` add_classifiction() `
148+
149+ ``` {r add-classification}
150+ z <- data.frame(
151+ estimate = c(-0.5, 0, 0.5, 1.5, 1, 0.5, 0, -0.5, -1, -1.5),
152+ sd = c(rep(0.8, 3), rep(0.3, 7))
153+ )
154+ z$lcl <- qnorm(0.05, z$estimate, z$sd)
155+ z$ucl <- qnorm(0.95, z$estimate, z$sd)
156+ classification(z$lcl, z$ucl, threshold = 1) -> z$effect
157+ z$x <- class_labels(type = "effect")[z$effect]
158+ z$x <- factor(z$x, z$x)
159+ z$display <- paste(
160+ "estimate:", format_ci(z$estimate, lcl = z$lcl, ucl = z$ucl)
161+ )
162+ plot_ly(z, x = ~x, y = ~estimate) |>
163+ add_fan(sd = ~sd, text = ~display) |>
164+ add_classification(lcl = ~lcl, ucl = ~ucl, threshold = 1) |>
165+ layout(
166+ hovermode = "x unified",
167+ shapes = reference_shape(threshold = 1),
168+ annotations = reference_text(threshold = 1)
169+ )
170+ ```
171+
147172## Reference
148173
149174The ` reference_shape() ` and ` reference_text() ` functions can be used to add a reference lines and text to the plot.
0 commit comments