diff --git a/DESCRIPTION b/DESCRIPTION index b5d64b2e..29ca554b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,7 +22,7 @@ Imports: recipes (>= 1.0.4), rsample, dplyr (>= 1.0.0), - ggplot2, + ggplot2 (>= 3.4.0), forcats, stringr, plotly, diff --git a/R/plot-acf_diagnostics.R b/R/plot-acf_diagnostics.R index 7015a562..8e17ade8 100644 --- a/R/plot-acf_diagnostics.R +++ b/R/plot-acf_diagnostics.R @@ -18,7 +18,7 @@ #' @param .facet_ncol Facets: Number of facet columns. Has no effect if using `grouped_df`. #' @param .facet_scales Facets: Options include "fixed", "free", "free_y", "free_x" #' @param .line_color Line color. Use keyword: "scale_color" to change the color by the facet. -#' @param .line_size Line size +#' @param .line_size Line size (linewidth) #' @param .line_alpha Line opacity. Adjust the transparency of the line. Range: (0, 1) #' @param .point_color Point color. Use keyword: "scale_color" to change the color by the facet. #' @param .point_size Point size @@ -215,11 +215,11 @@ plot_acf_diagnostics.data.frame <- function(.data, .date_var, .value, .ccf_vars if (.line_color == "scale_color") { g <- g + ggplot2::geom_line(ggplot2::aes(color = name), - size = .line_size, alpha = .line_alpha) + + linewidth = .line_size, alpha = .line_alpha) + scale_color_tq() } else { g <- g + - ggplot2::geom_line(color = .line_color, size = .line_size, alpha = .line_alpha) + ggplot2::geom_line(color = .line_color, linewidth = .line_size, alpha = .line_alpha) } # Add points @@ -335,11 +335,11 @@ plot_acf_diagnostics.grouped_df <- function(.data, .date_var, .value, .ccf_vars if (.line_color == "scale_color") { g <- g + ggplot2::geom_line(ggplot2::aes(color = .groups_consolidated), - size = .line_size, alpha = .line_alpha) + + linewidth = .line_size, alpha = .line_alpha) + scale_color_tq() } else { g <- g + - ggplot2::geom_line(color = .line_color, size = .line_size, alpha = .line_alpha) + ggplot2::geom_line(color = .line_color, linewidth = .line_size, alpha = .line_alpha) } # Add points diff --git a/R/plot-anomaly_diagnostics.R b/R/plot-anomaly_diagnostics.R index a99034c1..6428c8a2 100644 --- a/R/plot-anomaly_diagnostics.R +++ b/R/plot-anomaly_diagnostics.R @@ -301,10 +301,10 @@ plot_anomaly_diagnostics.data.frame <- function( # Add line g <- g + ggplot2::geom_line( - color = .line_color, - size = .line_size, - linetype = .line_type, - alpha = .line_alpha + color = .line_color, + linewidth = .line_size, + linetype = .line_type, + alpha = .line_alpha ) # Add Outliers diff --git a/R/plot-time_series.R b/R/plot-time_series.R index 69e3a534..f614ebb8 100644 --- a/R/plot-time_series.R +++ b/R/plot-time_series.R @@ -361,19 +361,19 @@ plot_time_series.data.frame <- function( if (rlang::quo_is_null(color_var_expr)) { g <- g + ggplot2::geom_line( - color = .line_color, - size = .line_size, - linetype = .line_type, - alpha = .line_alpha + color = .line_color, + linewidth = .line_size, + linetype = .line_type, + alpha = .line_alpha ) } else { g <- g + ggplot2::geom_line( ggplot2::aes(color = .color_mod, group = .color_mod), - size = .line_size, - linetype = .line_type, - alpha = .line_alpha + linewidth = .line_size, + linetype = .line_type, + alpha = .line_alpha ) + scale_color_tq() } diff --git a/R/tidyquant-theme-compat.R b/R/tidyquant-theme-compat.R index 2fb917f9..a1973a68 100644 --- a/R/tidyquant-theme-compat.R +++ b/R/tidyquant-theme-compat.R @@ -15,10 +15,10 @@ theme_tq <- function(base_size = 11, base_family = "") { ggplot2::theme( # Base Inherited Elements - line = ggplot2::element_line(colour = blue, size = 0.5, linetype = 1, + line = ggplot2::element_line(colour = blue, linewidth = 0.5, linetype = 1, lineend = "butt"), rect = ggplot2::element_rect(fill = white, colour = blue, - size = 0.5, linetype = 1), + linewidth = 0.5, linetype = 1), text = ggplot2::element_text(family = base_family, face = "plain", colour = blue, size = base_size, lineheight = 0.9, hjust = 0.5, vjust = 0.5, angle = 0, @@ -27,14 +27,14 @@ theme_tq <- function(base_size = 11, base_family = "") { # Axes axis.line = ggplot2::element_blank(), axis.text = ggplot2::element_text(size = ggplot2::rel(0.8)), - axis.ticks = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)), + axis.ticks = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)), axis.title = ggplot2::element_text(size = ggplot2::rel(1.0)), # Panel panel.background = ggplot2::element_rect(fill = white, color = NA), - panel.border = ggplot2::element_rect(fill = NA, size = ggplot2::rel(1/2), color = blue), - panel.grid.major = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)), - panel.grid.minor = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)), + panel.border = ggplot2::element_rect(fill = NA, linewidth = ggplot2::rel(1/2), color = blue), + panel.grid.major = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)), + panel.grid.minor = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)), panel.grid.minor.x = ggplot2::element_blank(), panel.spacing = ggplot2::unit(.75, "cm"), @@ -70,12 +70,12 @@ theme_tq_dark <- function(base_size = 11, base_family = "") { ggplot2::theme( # Axes - axis.ticks = ggplot2::element_line(color = blue, size = ggplot2::rel(1/3)), + axis.ticks = ggplot2::element_line(color = blue, linewidth = ggplot2::rel(1/3)), # Panel panel.background = ggplot2::element_rect(fill = grey, color = NA), - panel.grid.major = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)), - panel.grid.minor = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)), + panel.grid.major = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)), + panel.grid.minor = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)), # Complete theme complete = TRUE @@ -95,12 +95,12 @@ theme_tq_green <- function(base_size = 11, base_family = "") { ggplot2::theme( # Axes - axis.ticks = ggplot2::element_line(color = blue, size = ggplot2::rel(1/3)), + axis.ticks = ggplot2::element_line(color = blue, linewidth = ggplot2::rel(1/3)), # Panel panel.background = ggplot2::element_rect(fill = green, color = NA), - panel.grid.major = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)), - panel.grid.minor = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)), + panel.grid.major = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)), + panel.grid.minor = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)), # Complete theme complete = TRUE diff --git a/man/plot_acf_diagnostics.Rd b/man/plot_acf_diagnostics.Rd index 16719105..ff7825b8 100644 --- a/man/plot_acf_diagnostics.Rd +++ b/man/plot_acf_diagnostics.Rd @@ -56,7 +56,7 @@ versus the \code{.value}. Useful for evaluating external lagged regressors.} \item{.line_color}{Line color. Use keyword: "scale_color" to change the color by the facet.} -\item{.line_size}{Line size} +\item{.line_size}{Line size (linewidth)} \item{.line_alpha}{Line opacity. Adjust the transparency of the line. Range: (0, 1)}