mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-11-18 08:53:42 +00:00
R make rendering of plots by method plot_components optional (#551)
This commit is contained in:
parent
8b4e46fd1b
commit
e5967a541e
1 changed files with 12 additions and 8 deletions
20
R/R/plot.R
20
R/R/plot.R
|
|
@ -85,6 +85,8 @@ plot.prophet <- function(x, fcst, uncertainty = TRUE, plot_cap = TRUE,
|
||||||
#' @param yearly_start Integer specifying the start day of the yearly
|
#' @param yearly_start Integer specifying the start day of the yearly
|
||||||
#' seasonality plot. 0 (default) starts the year on Jan 1. 1 shifts by 1 day
|
#' seasonality plot. 0 (default) starts the year on Jan 1. 1 shifts by 1 day
|
||||||
#' to Jan 2, and so on.
|
#' to Jan 2, and so on.
|
||||||
|
#' @param render_plot Boolean indicating if the plots should be rendered.
|
||||||
|
#' Set to FALSE if you want the function to only return the list of panels.
|
||||||
#'
|
#'
|
||||||
#' @return Invisibly return a list containing the plotted ggplot objects
|
#' @return Invisibly return a list containing the plotted ggplot objects
|
||||||
#'
|
#'
|
||||||
|
|
@ -92,7 +94,7 @@ plot.prophet <- function(x, fcst, uncertainty = TRUE, plot_cap = TRUE,
|
||||||
#' @importFrom dplyr "%>%"
|
#' @importFrom dplyr "%>%"
|
||||||
prophet_plot_components <- function(
|
prophet_plot_components <- function(
|
||||||
m, fcst, uncertainty = TRUE, plot_cap = TRUE, weekly_start = 0,
|
m, fcst, uncertainty = TRUE, plot_cap = TRUE, weekly_start = 0,
|
||||||
yearly_start = 0
|
yearly_start = 0, render_plot = TRUE
|
||||||
) {
|
) {
|
||||||
# Plot the trend
|
# Plot the trend
|
||||||
panels <- list(
|
panels <- list(
|
||||||
|
|
@ -131,13 +133,15 @@ prophet_plot_components <- function(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make the plot.
|
if (render_plot) {
|
||||||
grid::grid.newpage()
|
# Make the plot.
|
||||||
grid::pushViewport(grid::viewport(layout = grid::grid.layout(length(panels),
|
grid::grid.newpage()
|
||||||
1)))
|
grid::pushViewport(grid::viewport(layout = grid::grid.layout(length(panels),
|
||||||
for (i in seq_along(panels)) {
|
1)))
|
||||||
print(panels[[i]], vp = grid::viewport(layout.pos.row = i,
|
for (i in seq_along(panels)) {
|
||||||
layout.pos.col = 1))
|
print(panels[[i]], vp = grid::viewport(layout.pos.row = i,
|
||||||
|
layout.pos.col = 1))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(invisible(panels))
|
return(invisible(panels))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue