@@ -56,19 +56,18 @@ plot.sparsegl <- function(x,
5656 }
5757
5858 n_legend_values <- nrow(xb )
59- df <- as.data.frame(t(as.matrix(xb )))
60-
61- df $ lambda <- x $ lambda
62- df $ penalty <- sgnorm / max(sgnorm )
63- df <- tidyr :: pivot_longer(df , ! c(.data $ lambda , .data $ penalty ), names_to = y_axis )
59+ df <- data.frame (
60+ lambda = rep(x $ lambda , times = nrow(xb )),
61+ penalty = rep(sgnorm / max(sgnorm ), times = nrow(xb )),
62+ value = as.vector(t(as.matrix(xb )))
63+ )
64+ df [[y_axis ]] <- rep(rownames(xb ), each = ncol(xb ))
6465
6566 plot_layer <- ggplot2 :: ggplot(
6667 df , ggplot2 :: aes(
6768 x = !! rlang :: sym(x_axis ), y = .data $ value , color = !! rlang :: sym(y_axis )
6869 )
69- ) +
70- ggplot2 :: geom_hline(yintercept = 0 )
71-
70+ )
7271 if (x_axis == " penalty" ) {
7372 xlab_layer <- ggplot2 :: xlab(" penalty / max (penalty)" )
7473 }
@@ -91,6 +90,8 @@ plot.sparsegl <- function(x,
9190 theme_layer <- theme_layer + ggplot2 :: theme(legend.position = " none" )
9291 }
9392
94- p <- plot_layer + xlab_layer + legend_layer + theme_layer
93+ p <- plot_layer + xlab_layer + legend_layer + theme_layer +
94+ ggplot2 :: geom_hline(yintercept = 0 )
95+
9596 return (p )
9697}
0 commit comments