-
Notifications
You must be signed in to change notification settings - Fork 641
Expand file tree
/
Copy pathgeom_boxplot2.R
More file actions
25 lines (25 loc) · 932 Bytes
/
geom_boxplot2.R
File metadata and controls
25 lines (25 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#' Attempt to convert `geom_boxplot()` to a plotly.js box trace
#'
#' There are two ways to create boxplot via [ggplotly()]: with either
#' this function or [ggplot2::geom_boxplot()]. This function uses
#' the [box](https://plot.ly/r/reference/#box) trace type whereas the
#' latter uses a combination of [scatter](https://plot.ly/r/reference/#scatter)
#' traces to render the visualization. This implies that, this
#' function lets plotly.js compute boxplot summaries and positional
#' dodging, whereas the latter uses the actual ggplot2 boxplot
#' definition(s).
#'
#' @param ... arguments passed along to [ggplot2::geom_boxplot()]
#'
#' @export
#' @examples
#'
#' subplot(
#' ggplot(diamonds) + geom_boxplot(aes(y = price)),
#' ggplot(diamonds) + geom_boxplot2(aes(y = price))
#' )
geom_boxplot2 <- function(...) {
ggproto_box <- ggplot2::geom_boxplot(...)
ggproto_box$plotlyGeomBoxplot2 <- TRUE
ggproto_box
}