Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ggplot2 (development version)

* Strip padding in `facet_grid()` is now only in effect if `strip.placement = "outside"`
_and_ an axis is present between the strip and the panel (@thomasp85, #4610)

* Setting `stroke` to `NA` in `geom_point()` will no longer impair the sizing of
the points (@thomasp85, #4624)

Expand Down
20 changes: 12 additions & 8 deletions R/facet-grid-.r
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,14 @@ FacetGrid <- ggproto("FacetGrid", Facet,
theme$panel.spacing.y %||% theme$panel.spacing)

# Add axes
panel_table <- gtable_add_rows(panel_table, max_height(axes$x$top), 0)
panel_table <- gtable_add_rows(panel_table, max_height(axes$x$bottom), -1)
panel_table <- gtable_add_cols(panel_table, max_width(axes$y$left), 0)
panel_table <- gtable_add_cols(panel_table, max_width(axes$y$right), -1)
axis_height_top <- max_height(axes$x$top)
axis_height_bottom <- max_height(axes$x$bottom)
axis_width_left <- max_width(axes$y$left)
axis_width_right <- max_width(axes$y$right)
panel_table <- gtable_add_rows(panel_table, axis_height_top, 0)
panel_table <- gtable_add_rows(panel_table, axis_height_bottom, -1)
panel_table <- gtable_add_cols(panel_table, axis_width_left, 0)
panel_table <- gtable_add_cols(panel_table, axis_width_right, -1)
panel_pos_col <- panel_cols(panel_table)
panel_pos_rows <- panel_rows(panel_table)

Expand All @@ -377,7 +381,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
panel_pos_col <- panel_cols(panel_table)
if (switch_x) {
if (!is.null(strips$x$bottom)) {
if (inside_x) {
if (inside_x || as.numeric(axis_height_bottom) == 0) {
panel_table <- gtable_add_rows(panel_table, max_height(strips$x$bottom), -2)
panel_table <- gtable_add_grob(panel_table, strips$x$bottom, -2, panel_pos_col$l, clip = "on", name = paste0("strip-b-", seq_along(strips$x$bottom)), z = 2)
} else {
Expand All @@ -388,7 +392,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
}
} else {
if (!is.null(strips$x$top)) {
if (inside_x) {
if (inside_x || as.numeric(axis_height_top) == 0) {
panel_table <- gtable_add_rows(panel_table, max_height(strips$x$top), 1)
panel_table <- gtable_add_grob(panel_table, strips$x$top, 2, panel_pos_col$l, clip = "on", name = paste0("strip-t-", seq_along(strips$x$top)), z = 2)
} else {
Expand All @@ -401,7 +405,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
panel_pos_rows <- panel_rows(panel_table)
if (switch_y) {
if (!is.null(strips$y$left)) {
if (inside_y) {
if (inside_y || as.numeric(axis_width_left) == 0) {
panel_table <- gtable_add_cols(panel_table, max_width(strips$y$left), 1)
panel_table <- gtable_add_grob(panel_table, strips$y$left, panel_pos_rows$t, 2, clip = "on", name = paste0("strip-l-", seq_along(strips$y$left)), z = 2)
} else {
Expand All @@ -412,7 +416,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
}
} else {
if (!is.null(strips$y$right)) {
if (inside_y) {
if (inside_y || as.numeric(axis_width_right) == 0) {
panel_table <- gtable_add_cols(panel_table, max_width(strips$y$right), -2)
panel_table <- gtable_add_grob(panel_table, strips$y$right, panel_pos_rows$t, -2, clip = "on", name = paste0("strip-r-", seq_along(strips$y$right)), z = 2)
} else {
Expand Down