diff --git a/NEWS.md b/NEWS.md index b2c70e3..25aaf5c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # ggseqplot 0.8.4 +* fixed #3: haven_labelled group vars are converted into factors before plotting +* fixed #4: legends display key glyph for non-visited states (this wasn't the case anymore due to `{ggplot2}` release 3.5.0) + + # ggseqplot 0.8.3 * added missing minimum versions for dependencies & imports (ggplot2, dplyr, forcats) diff --git a/R/ggseqdplot.R b/R/ggseqdplot.R index 2cb8f20..df2f45b 100644 --- a/R/ggseqdplot.R +++ b/R/ggseqdplot.R @@ -276,14 +276,16 @@ ggseqdplot <- function(seqdata, ggplot(aes(fill = .data$state, y = .data$value, x = .data$x)) + geom_bar( stat = "identity", - width = 1 + width = 1, + show.legend = T ) } else { ggdplot <- dplotdata |> ggplot(aes(fill = .data$state, y = .data$value, x = .data$x)) + geom_bar( stat = "identity", - width = 1, color = "black" + width = 1, color = "black", + show.legend = T ) } diff --git a/R/ggseqiplot.R b/R/ggseqiplot.R index 7f57f6b..ea13b61 100644 --- a/R/ggseqiplot.R +++ b/R/ggseqiplot.R @@ -432,7 +432,7 @@ ggseqiplot <- function(seqdata, ymin = .data$begin, ymax = .data$end, fill = .data$states, colour = .data$states )) + - geom_rect() + + geom_rect(show.legend = T) + scale_fill_manual(values = cpal, drop = FALSE) + scale_color_manual(values = cpal, drop = FALSE) + theme_minimal() + @@ -450,7 +450,8 @@ ggseqiplot <- function(seqdata, ymin = .data$begin, ymax = .data$end, fill = .data$states )) + - geom_rect(colour = "black") + + geom_rect(colour = "black", + show.legend = T) + scale_fill_manual(values = cpal, drop = FALSE) + scale_color_manual(values = cpal, drop = FALSE) + theme_minimal() + diff --git a/R/ggseqmsplot.R b/R/ggseqmsplot.R index f0d8ac6..8ac8148 100644 --- a/R/ggseqmsplot.R +++ b/R/ggseqmsplot.R @@ -184,13 +184,16 @@ ggseqmsplot <- function(seqdata, if (border == FALSE) { ggmsplot <- msplotdata |> ggplot(aes(fill = .data$state, y = .data$value, x = .data$x)) + - geom_bar(stat="identity", width = barwidth) + geom_bar(stat="identity", + width = barwidth, + show.legend = T) } else { ggmsplot <- msplotdata |> ggplot(aes(fill = .data$state, y = .data$value, x = .data$x)) + geom_bar(stat="identity", width = barwidth, - color = "black") + color = "black", + show.legend = T) } ggmsplot <- ggmsplot + diff --git a/R/ggseqmtplot.R b/R/ggseqmtplot.R index 04335af..551c40f 100644 --- a/R/ggseqmtplot.R +++ b/R/ggseqmtplot.R @@ -163,7 +163,8 @@ ggseqmtplot <- function(seqdata, ggplot(aes(x = .data$state, fill = .data$labels)) + geom_bar(aes(y = .data$Mean), stat="identity", color = ifelse(border == TRUE, "black", - "transparent")) + + "transparent"), + show.legend = T) + scale_y_continuous(expand = expansion(add = 0)) + scale_fill_manual(drop = FALSE, values = cpal) +