title: Aligning grid lines to axis ticks in lattice graphics
body: <p>Is there a way to align grid lines if they are chosen custom?
  By default, panel.grid(h=-1,v=-1) does the job, but I'd like to refine the grid according to the axis ticks. Setting h and v to negative lengths of axis ticks doesn't always work.</p>
  
  <p>Update: Below is an example. I would like to achieve that horizontal grid lines match the y-axis ticks. Currently half of horizontal grid lines are missing.</p>
  
  <pre><code>library(lattice)
  
  G &lt;- cut(trees$Girth, seq(8, 22, by = 3))
  p &lt;- xyplot(Height ~ Volume | G, data = trees,
            scales = list(x = list(alternating = 3, at = seq(10, 60, by = 5)),
                          y = list(alternating = 3, at = seq(65, 85, by = 2.5))),
            panel = function(x, y, ...){
                panel.grid(v = -11, h = -9)
                panel.xyplot(x, y, ...)})
  print(p)
  </code></pre>
  
  <p>What I currently get is this:</p>
  
  <p><img src="https://i.stack.imgur.com/QzeSN.png" alt="enter image description here"></p>