[R] controlling lattice plot ticks with relation="free"

Richard.Cotton at hsl.gov.uk Richard.Cotton at hsl.gov.uk
Fri Sep 5 17:16:13 CEST 2008


> How do you persuade lattice to draw tick marks on both the left and 
right 
> side of the y-axis, when relation="free" in the scales component?
> 
> #Ticks appear on both sides
> histogram(~height|voice.part, data=singer)
> 
> ##Ticks only on left
> histogram(~height|voice.part, data=singer, 
> scales=list(y=list(relation="free")))

I had an off list reply that was very helpful, suggesting the use of 
panel.axis.   For posterity, here's my own answer to my problem, using 
yscale.component. It's not a particularly natural solution, and it 
requires manually increasing the horizontal spacing between plots (with 
the between agrument), but it works.

myyscale.component <- function(...)
{
  ans <- yscale.components.default(...)
  ans$right <- ans$left
  ans$right$labels$labels <- NULL
  ans
} 

histogram(~height|voice.part, data=singer, 
   scales=list(y=list(relation="free")),
   yscale.component=myyscale.component,
   between=list(x=.5))

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}



More information about the R-help mailing list