diff --git a/R/g_lineplot.R b/R/g_lineplot.R index ac6bc712..35da3ff3 100644 --- a/R/g_lineplot.R +++ b/R/g_lineplot.R @@ -29,6 +29,7 @@ #' Default value is `ggplot2::waiver()`. #' @param rotate_xlab boolean whether to rotate x-axis labels. #' @param plot_font_size control font size for title, x-axis, y-axis and legend font. +#' @param dot_size plot dot size. Default to 3. #' @param dodge control position dodge. #' @param plot_height height of produced plot. 989 pixels by default. #' @param count_threshold \code{integer} minimum number observations needed to show the appropriate @@ -207,7 +208,8 @@ #' xtick = c(0, 1, 5), #' xlabel = c("Baseline", "Week 1", "Week 5"), #' rotate_xlab = FALSE, -#' plot_height = 1500 +#' plot_height = 1500, +#' dot_size = 1 #' ) #' #' g_lineplot( @@ -227,7 +229,8 @@ #' xtick = c(0, 1, 5), #' xlabel = c("Baseline", "Week 1", "Week 5"), #' rotate_xlab = FALSE, -#' plot_height = 1500 +#' plot_height = 1500, +#' dot_size = 4 #' ) g_lineplot <- function(label = "Line Plot", data, @@ -254,6 +257,7 @@ g_lineplot <- function(label = "Line Plot", xlabel = xtick, rotate_xlab = FALSE, plot_font_size = 12, + dot_size = 3, dodge = 0.4, plot_height = 989, count_threshold = 0, @@ -405,7 +409,7 @@ g_lineplot <- function(label = "Line Plot", ) ) + ggplot2::theme_bw() + - ggplot2::geom_point(position = pd) + + ggplot2::geom_point(position = pd, size = dot_size) + ggplot2::scale_color_manual( values = color_manual, name = trt_label, guide = ggplot2::guide_legend(ncol = 3, order = 1) ) + @@ -443,7 +447,7 @@ g_lineplot <- function(label = "Line Plot", ggplot2::scale_linetype_manual(" ", values = type_mapping, guide = ggplot2::guide_legend(ncol = 3, order = 1)) + ggplot2::scale_shape_manual(" ", values = shape_mapping, guide = ggplot2::guide_legend(ncol = 3, order = 1)) + ggplot2::theme(legend.key.size = grid::unit(1, "cm")) + - ggplot2::geom_point(position = pd, size = 3) + ggplot2::geom_point(position = pd, size = dot_size) } plot1 <- plot1 + diff --git a/R/g_spaghettiplot.R b/R/g_spaghettiplot.R index d1585cf1..9b0e01f0 100644 --- a/R/g_spaghettiplot.R +++ b/R/g_spaghettiplot.R @@ -30,6 +30,7 @@ #' value is `ggplot2::waiver()`. #' @param rotate_xlab boolean whether to rotate x-axis labels. #' @param font_size control font size for title, x-axis, y-axis and legend font. +#' @param dot_size plot dot size. Default to 2. #' @param group_stats control group mean or median overlay. #' @param hline_arb ('numeric vector') value identifying intercept for arbitrary horizontal lines. #' @param hline_arb_color ('character vector') optional, color for the arbitrary horizontal lines. @@ -145,7 +146,8 @@ #' group_stats = "median", #' hline_arb = 1.3, #' hline_vars = c("ANRHI", "ANRLO", "ULOQN", "LLOQN"), -#' hline_vars_colors = c("pink", "brown", "purple", "gray") +#' hline_vars_colors = c("pink", "brown", "purple", "gray"), +#' dot_size = 3 #' ) #' #' g_spaghettiplot( @@ -166,7 +168,8 @@ #' hline_arb = c(.5, .7, 1), #' hline_arb_color = c("blue", "red", "green"), #' hline_arb_label = c("Arb_Hori_line_A", "Arb_Hori_line_B", "Arb_Hori_line_C"), -#' hline_vars = c("ANRHI", "ANRLO") +#' hline_vars = c("ANRHI", "ANRLO"), +#' dot_size = 4 #' ) #' #' # removing missing levels from the plot with facet_scales @@ -208,7 +211,8 @@ #' hline_arb = c(.5, .7, 1), #' hline_arb_color = c("blue", "red", "green"), #' hline_arb_label = c("Arb_Hori_line_A", "Arb_Hori_line_B", "Arb_Hori_line_C"), -#' hline_vars = c("ANRHI", "ANRLO") +#' hline_vars = c("ANRHI", "ANRLO"), +#' dot_size = 1 #' ) #' g_spaghettiplot <- function(data, @@ -233,6 +237,7 @@ g_spaghettiplot <- function(data, xlabel = xtick, rotate_xlab = FALSE, font_size = 12, + dot_size = 2, group_stats = "NONE", hline_arb = numeric(0), hline_arb_color = "red", @@ -288,7 +293,7 @@ g_spaghettiplot <- function(data, data = plot_data, ggplot2::aes(x = !!sym(time), y = !!sym(value_var), color = !!sym(trt_group), group = !!sym(subj_id)) ) + - ggplot2::geom_point(size = 0.8, na.rm = TRUE, ggplot2::aes(shape = !!sym(loq_flag_var))) + + ggplot2::geom_point(size = dot_size, na.rm = TRUE, ggplot2::aes(shape = !!sym(loq_flag_var))) + ggplot2::geom_line(linewidth = 0.4, alpha = alpha, na.rm = TRUE) + ggplot2::facet_wrap(trt_group, ncol = facet_ncol, scales = facet_scales) + ggplot2::labs(caption = caption_loqs_label) + diff --git a/man/g_lineplot.Rd b/man/g_lineplot.Rd index 225f41ce..49801cdb 100644 --- a/man/g_lineplot.Rd +++ b/man/g_lineplot.Rd @@ -30,6 +30,7 @@ g_lineplot( xlabel = xtick, rotate_xlab = FALSE, plot_font_size = 12, + dot_size = 3, dodge = 0.4, plot_height = 989, count_threshold = 0, @@ -92,6 +93,8 @@ Default value is \code{ggplot2::waiver()}.} \item{plot_font_size}{control font size for title, x-axis, y-axis and legend font.} +\item{dot_size}{plot dot size. Default to 3.} + \item{dodge}{control position dodge.} \item{plot_height}{height of produced plot. 989 pixels by default.} @@ -273,7 +276,8 @@ g_lineplot( xtick = c(0, 1, 5), xlabel = c("Baseline", "Week 1", "Week 5"), rotate_xlab = FALSE, - plot_height = 1500 + plot_height = 1500, + dot_size = 1 ) g_lineplot( @@ -293,7 +297,8 @@ g_lineplot( xtick = c(0, 1, 5), xlabel = c("Baseline", "Week 1", "Week 5"), rotate_xlab = FALSE, - plot_height = 1500 + plot_height = 1500, + dot_size = 4 ) } \author{ diff --git a/man/g_spaghettiplot.Rd b/man/g_spaghettiplot.Rd index ccaa5780..81b40724 100644 --- a/man/g_spaghettiplot.Rd +++ b/man/g_spaghettiplot.Rd @@ -27,6 +27,7 @@ g_spaghettiplot( xlabel = xtick, rotate_xlab = FALSE, font_size = 12, + dot_size = 2, group_stats = "NONE", hline_arb = numeric(0), hline_arb_color = "red", @@ -87,6 +88,8 @@ value is \code{ggplot2::waiver()}.} \item{font_size}{control font size for title, x-axis, y-axis and legend font.} +\item{dot_size}{plot dot size. Default to 2.} + \item{group_stats}{control group mean or median overlay.} \item{hline_arb}{('numeric vector') value identifying intercept for arbitrary horizontal lines.} @@ -207,7 +210,8 @@ g_spaghettiplot( group_stats = "median", hline_arb = 1.3, hline_vars = c("ANRHI", "ANRLO", "ULOQN", "LLOQN"), - hline_vars_colors = c("pink", "brown", "purple", "gray") + hline_vars_colors = c("pink", "brown", "purple", "gray"), + dot_size = 3 ) g_spaghettiplot( @@ -228,7 +232,8 @@ g_spaghettiplot( hline_arb = c(.5, .7, 1), hline_arb_color = c("blue", "red", "green"), hline_arb_label = c("Arb_Hori_line_A", "Arb_Hori_line_B", "Arb_Hori_line_C"), - hline_vars = c("ANRHI", "ANRLO") + hline_vars = c("ANRHI", "ANRLO"), + dot_size = 4 ) # removing missing levels from the plot with facet_scales @@ -270,7 +275,8 @@ g_spaghettiplot( hline_arb = c(.5, .7, 1), hline_arb_color = c("blue", "red", "green"), hline_arb_label = c("Arb_Hori_line_A", "Arb_Hori_line_B", "Arb_Hori_line_C"), - hline_vars = c("ANRHI", "ANRLO") + hline_vars = c("ANRHI", "ANRLO"), + dot_size = 1 ) }