Manipulate y axis scale with ggforce facet_zoom

I am drawing a time series, and I want to increase the number of observations. This can be done using facet_zoom()from the package ggforce.

library(dplyr)
library(ggplot2)
library(ggforce)
library(stringr)


airquality %>% 
  mutate(month_day = seq(as.Date("2000/1/1"), 
                         by = "month", 
                         length.out = n())) %>% 
  ggplot(aes(x = month_day, y = Temp)) + 
  geom_line() +
  facet_zoom(x = month_day > "2010/1/1" & month_day < "2010/9/1")

Result:

enter image description here

However, I would like to manipulate the scale along the Y axis of the bottom section of the panel, making it smaller. Is there any way to do this?

+4
source share
1 answer

Use xyinstead xand set horizontalto TRUEto automatically set the y axis:

airquality %>% 
  mutate(month_day = seq(as.Date("2000/1/1"), 
                         by = "month", 
                         length.out = n())) %>% 
  ggplot(aes(x = month_day, y = Temp)) + 
  geom_line() +
  facet_zoom(xy = month_day > "2010/1/1" & month_day < "2010/9/1", horizontal = FALSE)

enter image description here

+3
source

Source: https://habr.com/ru/post/1671600/


All Articles