diff --git a/R/plot_functions.R b/R/plot_functions.R index a083779264f62908bb572563e436ffd22ec08244..35fd1586c48836f6d98be5e9817350537357133f 100644 --- a/R/plot_functions.R +++ b/R/plot_functions.R @@ -201,9 +201,10 @@ plot_selection <- function(x, sel.type, threshold) { alpha = 0.2) } else if (!basics) { # not basics, 'range_at' all_levels <- seq(0.7, 1, length.out = length(x$selected)) - dfline <- mapply(function(a, b) { - make_line_df(a, var_names = var_names, level = b) - }, x$selected, all_levels, SIMPLIFY = FALSE) + all_levels2 <- seq(0, 0.3, length.out = length(x$selected)) + dfline <- mapply(function(a, b, d) { + make_line_df(a, var_names = var_names, level = b, level2 = d) + }, x$selected, all_levels, all_levels2, SIMPLIFY = FALSE) all_at <- sapply(dfline, nrow) all_at <- rep(names(dfline), all_at) @@ -212,7 +213,7 @@ plot_selection <- function(x, sel.type, threshold) { p <- ggplot(data = dfline, aes(group = at, colour = at)) } else if (lobj == 1) { # basics, 'at' sel_mean <- x$selected[[1]]$variable[x$selected[[1]]$"in.mean"] - dfline_mean <- make_line_df(sel_mean, var_names) + dfline_mean <- make_line_df(sel_mean, var_names, level2 = 0.2) sel_sd <- x$selected[[1]]$variable[x$selected[[1]]$"in.sd"] dfline_sd <- make_line_df(sel_sd, var_names, level = 0.8) dfline <- rbind(dfline_mean, dfline_sd) @@ -229,9 +230,10 @@ plot_selection <- function(x, sel.type, threshold) { df <- c(dfmean, dfsd) all_levels <- seq(0.7, 1, length.out = length(df)) - dfline <- mapply(function(a, b) { - make_line_df(a, var_names = var_names, level = b) - }, df, all_levels, SIMPLIFY = FALSE) + all_levels2 <- seq(0, 0.3, length.out = length(df)) + dfline <- mapply(function(a, b, d) { + make_line_df(a, var_names = var_names, level = b, level2 = d) + }, df, all_levels, all_levels2, SIMPLIFY = FALSE) all_at <- sapply(dfline, nrow) all_at <- rep(names(dfline), all_at) @@ -389,7 +391,7 @@ fill_na <- function(dataset, var) { return(dataset) } -make_line_df <- function(selected, var_names, level = 1) { +make_line_df <- function(selected, var_names, level = 1, level2 = 0) { which_sel <- match(selected, var_names) if (length(which_sel) > 0 & length(which_sel) < length(var_names)) { diff_which <- diff(which_sel) @@ -405,8 +407,8 @@ make_line_df <- function(selected, var_names, level = 1) { starts <- c(which_sel[1], which_sel[starts]) ends <- which(diff_which > 1) ends <- c(which_sel[ends], which_sel[length(which_sel)]) - df2 <- data.frame("xstart" = starts, "ystart" = rep(0, length(starts)), - "xend" = ends, "yend" = rep(0, length(starts))) + df2 <- data.frame("xstart" = starts, "ystart" = rep(level2, length(starts)), + "xend" = ends, "yend" = rep(level2, length(starts))) df <- rbind(df, df2) } else if (length(which_sel) == 0) { df <- data.frame("xstart" = 1, "ystart" = 0, "xend" = length(var_names),