Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

241: adding parameter to adjust dot size. #242

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions R/g_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -254,6 +257,7 @@ g_lineplot <- function(label = "Line Plot",
xlabel = xtick,
rotate_xlab = FALSE,
plot_font_size = 12,
dot_size = 3,
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
dodge = 0.4,
plot_height = 989,
count_threshold = 0,
Expand Down Expand Up @@ -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)
) +
Expand Down Expand Up @@ -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 +
Expand Down
13 changes: 9 additions & 4 deletions R/g_spaghettiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -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) +
Expand Down
9 changes: 7 additions & 2 deletions man/g_lineplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions man/g_spaghettiplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading