Skip to content

Commit

Permalink
Fix #325
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Aug 9, 2023
1 parent 087ca91 commit 629d263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
together (#277)
* Patchworks will now render correctly when unserialised in a fresh session,
providing the patchwork package is available (#242)
* Fixed a bug preventing faceted plots with strip placement outside the axis
from being aligned (#325)

# patchwork 1.1.2

Expand Down
8 changes: 5 additions & 3 deletions R/plot_patchwork.R
Original file line number Diff line number Diff line change
Expand Up @@ -633,19 +633,21 @@ add_strips <- function(gt) {
)
if (!any(grepl('strip-b', gt$layout$name))) {
gt <- gtable_add_rows(gt, unit(0, 'mm'), panel_loc$b + strip_pos)
} else if (strip_pos == 2) {
} else if (strip_pos == 2 && !any(gt$layout$b == panel_loc$b + 2)) {
# Merge the strip-gap height into the axis and remove it. Only performed if
# an axis exist
gt$heights[panel_loc$b + 1] <- sum(gt$heights[panel_loc$b + c(1, 2)])
gt <- gt[-(panel_loc$b + 2), ]
}
if (!any(grepl('strip-t', gt$layout$name))) {
gt <- gtable_add_rows(gt, unit(0, 'mm'), panel_loc$t - 1 - strip_pos)
} else if (strip_pos == 2) {
} else if (strip_pos == 2 && !any(gt$layout$t == panel_loc$t - 2)) {
gt$heights[panel_loc$t - 1] <- sum(gt$heights[panel_loc$t - c(1, 2)])
gt <- gt[-(panel_loc$t - 2), ]
}
if (!any(grepl('strip-r', gt$layout$name))) {
gt <- gtable_add_cols(gt, unit(0, 'mm'), panel_loc$r + strip_pos)
} else if (strip_pos == 2) {
} else if (strip_pos == 2 && !any(gt$layout$r == panel_loc$r + 2)) {
gt$widths[panel_loc$r + 1] <- sum(gt$widths[panel_loc$r + c(1, 2)])
gt <- gt[, -(panel_loc$r + 2)]
}
Expand Down

0 comments on commit 629d263

Please sign in to comment.