title: Both geom_vline and geom_hline fails when faceting spatial map on ggplot2
body: <p>I am really careful before posting this this question, in order to avoid any duplication. So I intended to create a faceting map based on quarter, equipped with both major and minor grid, whereas the latitude and longitude labels only on major grid. Here is the MWE:</p>
  <pre><code>library(sf)
  library(rnaturalearth)
  
  sf::sf_use_s2(FALSE)
  
  dummy &lt;- data.frame(
    Lat1 = seq(-14.5, 4.5, by = 1),
    Lon1 = seq(105.5, 124.5, by = 1),
    quarter = rep(1:4, 10)
  )
  
  worldmap &lt;- ne_countries(scale = 'medium', type = 'map_units', returnclass = 'sf')
  wpp &lt;- st_crop(worldmap, ymin = -15, ymax = -5, xmin = 105, xmax = 125)
  
  minor.x &lt;- seq(105, 125, by = 1)
  minor.y &lt;- seq(-15, -5, by = 1)
  
  
  ggplot() +
    geom_sf(data = wpp, color = &quot;gray&quot;, fill = &quot;gray&quot;) +
    coord_sf(xlim=c(min(data.pie$Lon1-0.5),max(data.pie$Lon1)+0.5),
             ylim=c(min(data.pie$Lat1)-0.5,max(data.pie$Lat1)+0.5),
             expand = FALSE) +
    geom_hline(aes(yintercept = minor.y), color = &quot;gray&quot;, linetype = &quot;solid&quot;, size = 0.1) +
    geom_vline(aes(xintercept = minor.x), color = &quot;gray&quot;, linetype = &quot;solid&quot;, size = 0.1) +
    geom_point(data = dummy, aes(x = Lon1, y = Lat1), color= &quot;black&quot;) +
    
    xlab(&quot;Longitude&quot;) + ylab(&quot;Latitude&quot;) +
    
    scale_x_continuous(breaks = seq(105,125,2), minor_breaks = seq(106, 124, 2)) +
    scale_y_continuous(breaks = seq(-15,-5,2), minor_breaks = seq(-14, -4, 2)) +
    
    facet_wrap(~quarter) +
    
    theme_minimal() +
    theme(
      # panel.grid.minor = element_line(color = &quot;blue&quot;, size = 0.1),
      panel.grid.major = element_blank(),
      panel.background = element_rect(colour = &quot;black&quot;, size=0.5),
      legend.position = &quot;right&quot;,
      legend.title.align = 0.5,
      legend.text.align = 1) 
  </code></pre>
  <p>Without faceting I could produce the desired output<a href="https://i.stack.imgur.com/HFQjO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HFQjO.png" alt="the desired output" /></a></p>
  <p>However, when I use <code>facet_wrap(~quarter)</code> there was an error: <code>Error in FUN(X[[i]], ...) : subscript out of bounds</code></p>
  <p>I managed to produce a faceting map if I turned off the <code>geom_vline</code> and <code>geom_hline</code> but at the same time, I will lose the control over minor grid (only major was shown. Is there any workaround on this? PS. I am using the latest R and <code>ggplot()</code> version.</p>