Home > Back-end >  ggforce : force facet_zoom to set on the lateral side of the graph
ggforce : force facet_zoom to set on the lateral side of the graph

Time:11-05

Is there a way to force the zoom from the function facet_zoom() from the package ggforce on the lateral side of the graph instead of the bottom ?

I have this code

require(dplyr)
require(tidyverse)
require(ggforce)

g   facet_zoom(xlim = c(x1,x2)))

How should I proceed?

CodePudding user response:

ggplot(iris, aes(Petal.Length, Petal.Width, colour = Species))  
  geom_point()  
  facet_zoom(y = Species == 'versicolor')

Like this? (Zooming in on the y-axis)

CodePudding user response:

It is possible but it requires a bit of a hack. As far as I get it from the docs this could only be achieved when zooming both in the x and y direction. To this end you could set the zoom in the y direction to y=TRUE and afterwards set split=FALSE and horizontal = TRUE. Doing so will place the zoom panel on the left of the main plot. Additionally we have to get rid of the background fill for the zoom in the y direction via theme option zoom.y.

Using the example data and code from your former enter image description here

  • Related