title: Controlling axis ticks and axis lines separately on R lattice xyplot
body: <p>How can I go about removing the box around an <code>xyplot</code>, while keeping the axis scale tick marks? In the spirit of Edward Tufte's minimalist data graphic aesthetic, these axis lines are "non-data ink," and can (should?) be "erased."</p>
  
  <pre><code>library(lattice)
  my.df &lt;- data.frame(x=-10:10)
  my.df$y &lt;- my.df$x^2
  xyplot(y~x,data=my.df)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/VLbIa.jpg" alt="standard xyplot output"></p>
  
  <p>It seems that the trellis display parameters (e.g. <code>axis.line$col</code>) control both the axis lines and axis ticks together:</p>
  
  <pre><code>xyplot(y~x,data=my.df,
         par.settings=list(axis.line=list(col="transparent")))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ZGzf5.jpg" alt="with axis.line$col=&quot;transparent&quot;"></p>
  
  <p>...which is not the desired result, so it doesn't look like there's a simple way to turn off the lines while leaving the box.</p>
  
  <p>The best I've been able to come up with is a brute-force hack, where I build the tick marks by hand using <code>panel.segments</code>:</p>
  
  <pre><code>at.x=pretty(c(-10,10))
  at.y=pretty(c(0,100))
  xyplot(y~x,data=my.df,
         par.settings=list(axis.line=list(col="transparent")),
         scales=list(x=list(at=at.x,labels=at.x),
         y=list(at=at.y,labels=at.y)),
         panel=function(...){
             panel.xyplot(...)
             panel.segments(x0=at.x,x1=at.x,y0=-4,y1=-2)
             panel.segments(x0=-11.5,x1=-11,y0=at.y,y1=at.y)
         }
         )
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/XRIBE.jpg" alt="hand-made tick marks with panel.segments"></p>
  
  <p>This is close to the desired result, but there's quite a bit of fiddling required to get the tick marks to be a reasonable length and offset a "nice" distance from the data points. These values won't translate from one graphic to the next. Plus, note that the axis labels are now padded too far from the tick marks. I'm sure there's a way to reduce that padding, but that would only make the code even uglier and less portable.</p>
  
  <p>So how can one go about suppressing just the lines that make up the "box" around the plot area, while leaving the tick marks and axis labels intact? Bonus points if this approach could also be used to suppress some, but not all of the lines (e.g. leave the left and lower lines, but suppress the top and right lines).</p>