From bebadf44d242bf6482ca418d83d19c3e900998d8 Mon Sep 17 00:00:00 2001 From: Thomas Lin Pedersen Date: Sat, 26 Nov 2016 00:04:49 +0100 Subject: [PATCH] Fix #23 --- NEWS.md | 2 ++ R/facet_zoom.R | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index f2f02358..125cf3d7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ # ggforce 0.1.0.99 - Fix bug in facet_wrap_paginate that threw errors when using it with free scales (#19) +- Fixes bug in facet_zoom where y-axis would be incorrectly displayed when +zooming on both axes without splitting the view (#23) # ggforce 0.1.0 diff --git a/R/facet_zoom.R b/R/facet_zoom.R index 6794daf2..b0e02a76 100644 --- a/R/facet_zoom.R +++ b/R/facet_zoom.R @@ -111,9 +111,6 @@ FacetZoom <- ggproto("FacetDuplicate", Facet, d$PANEL <- panel d })) - if ('full' %in% layout$name && !params$split) { - data <- data[!data$PANEL %in% c(2L, 3L), ] - } data }, draw_panels = function(panels, layout, x_scales, y_scales, ranges, coord, @@ -130,6 +127,10 @@ FacetZoom <- ggproto("FacetDuplicate", Facet, axes <- render_axes(ranges, ranges, coord, theme, FALSE) panelGrobs <- create_panels(panels, axes$x, axes$y) + if ('full' %in% layout$name && !params$split) { + panelGrobs <- panelGrobs[c(1, 4)] + } + if ('y' %in% layout$name) { zoom_prop <- rescale(y_scales[[2]]$dimension(), from = y_scales[[1]]$dimension()) indicator <- polygonGrob(c(1, 1, 0, 0), c(zoom_prop, 1, 0), gp = gpar(col = NA, fill = alpha(theme$zoom$fill, 0.5)))