diff --git a/R/g_lineplot.R b/R/g_lineplot.R index 35da3ff3..7643a7f8 100644 --- a/R/g_lineplot.R +++ b/R/g_lineplot.R @@ -390,6 +390,7 @@ g_lineplot <- function(label = "Line Plot", gtitle <- paste0(biomarker1, unit1, stringr::str_to_title(line), " by Treatment @ Visits") gylab <- paste0(biomarker1, " ", stringr::str_to_title(line), " of ", value_var, " Values") + gxlab <- if (is.null(attr(data[[time]], "label"))) time else attr(data[[time]], "label") # Setup legend label trt_label <- `if`(is.null(attr(data[[trt_group]], "label")), "Dose", attr(data[[trt_group]], "label")) @@ -463,7 +464,7 @@ g_lineplot <- function(label = "Line Plot", "For median, the bar denotes the first to third quartile.\n", caption_loqs_label )) + - ggplot2::xlab(time) + + ggplot2::xlab(gxlab) + ggplot2::ylab(gylab) + ggplot2::theme( legend.box = "vertical", diff --git a/R/g_spaghettiplot.R b/R/g_spaghettiplot.R index 9046d69a..9043689d 100644 --- a/R/g_spaghettiplot.R +++ b/R/g_spaghettiplot.R @@ -259,6 +259,7 @@ g_spaghettiplot <- function(data, xtype <- ifelse(is.factor(data[[time]]) | is.character(data[[time]]), "discrete", "continuous") + gxlab <- if (is.null(attr(data[[time]], "label"))) time else attr(data[[time]], "label") if (xtype == "discrete") { data[[time]] <- if (!is.null(time_level)) { factor(data[[time]], levels = time_level) @@ -280,7 +281,6 @@ g_spaghettiplot <- function(data, unique() %>% magrittr::extract2(1) gtitle <- paste0(biomarker1, unit1, " Values by Treatment @ Visits") - gxlab <- if (is.null(attr(data[[time]], "label"))) time else attr(data[[time]], "label") gylab <- paste0(biomarker1, " ", value_var, " Values") # Setup legend label