-
Notifications
You must be signed in to change notification settings - Fork 6
/
ggla_plotly_settings.R
35 lines (32 loc) · 1.5 KB
/
ggla_plotly_settings.R
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
26
27
28
29
30
31
32
33
34
35
#' @title ggla_plotly_settings
#' @description AAdds default ggla layout, style and config to a plotly plot
#' @param plot A plotly plot, created either using plot_ly or ggplotly.
#' @param gla_theme Either "default" or "inverse", Default: 'default'
#' @param x_axis_title boolean, If TRUE an x-axis label/title can be added, Default: FALSE
#' @param y_axis_title boolean, If TRUE a y-axis label/title can be added, Default: FALSE
#' @param xgridlines boolean, If TRUE, theme will include gridlines on the x-axis, Default: FALSE
#' @param legend boolean, If TRUE, theme will include a legend at the top left of the plot, Default: TRUE
#' @param base_size base font size, Default: 14
#' @param ... Other parameters passed to plotly::layout
#' @return A plotly plot
#' @examples
#' \dontrun{
#' if(interactive()){
#' #EXAMPLE1
#' }
#' }
#' @rdname ggla_plotly_settings
#' @export
ggla_plotly_settings <- function(plot, gla_theme = "default",
x_axis_title = FALSE, y_axis_title = FALSE,
xgridlines = FALSE, legend = TRUE,
base_size = 14, ...) {
ggla_plotly <- plot %>%
ggla_plotly_layout(gla_theme = gla_theme,
x_axis_title = x_axis_title, y_axis_title = y_axis_title,
xgridlines = xgridlines, legend = legend,
base_size = base_size, ...) %>%
ggla_plotly_style(gla_theme = gla_theme, base_size = base_size) %>%
ggla_plotly_config()
return(ggla_plotly)
}