Skip to content

Commit

Permalink
fixed #4: show all key glyphs; even if states are not observed
Browse files Browse the repository at this point in the history
  • Loading branch information
maraab23 committed May 17, 2024
1 parent 8582593 commit 878feae
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 4 additions & 2 deletions R/ggseqdplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down
5 changes: 3 additions & 2 deletions R/ggseqiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() +
Expand All @@ -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() +
Expand Down
7 changes: 5 additions & 2 deletions R/ggseqmsplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down
3 changes: 2 additions & 1 deletion R/ggseqmtplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down

0 comments on commit 878feae

Please sign in to comment.