[R] lattice levelplot axis ticks labels

Larry York larry.york at gmail.com
Sun Apr 1 13:26:57 CEST 2012


Hello,

I've searched for help a lot and think I am close, but an still not able to
place ticks and labels how I'd like in lattice's levelplot. I've come up
with general reproducible code that gives the same problem as I'm having
with real data:

heat <- array(1:24,c(3,8))

require (lattice)

##basically I want a graph like this. depth y axis doesn't have ticks and
labels at each place, but i want a tick and label at each value. through
time x has ticks and labels where there isn't data, i don't want that! even
better would be if i could get a nice hedding to give units on the key. i
want ticks and labels at 1:8 for y and 1:3 for x

levelplot(heat,row.values=1:3,column.values=1:8,
          col.regions=heat.colors(20),
          main="Heat map with depth", 
          xlab="through time",
          ylab="depth",
          colorkey=list(col=heat.colors(20),
          )

##I think this is how I can force ticks and labels on y axis based on help I
saw on net, but I can't get it to work
          
## first make function to set up object to replace yscale.components.default
- i think that gives the automated 'pretty' axes

yscale.components.HEAT <- function(...)
  
  {
    ans <- yscale.components.default(...)
    ans$right <- ans$left
    ticklabels <- -1*seq(0,80,10)
    ans$left$ticks$at  <- ticklabels
    ans$left$labels$at <- ticklabels
    ans$left$labels$labels <- ticklabels
    ans
  }
          
#call on this replacement while plotting
          
levelplot(heat,row.values=1:3,column.values=1:8,
          col.regions=heat.colors(20),
          main="Heat map with depth", 
          xlab="through time",
          ylab="depth",
          colorkey=list(col=heat.colors(20)),
          yscale.components = yscale.components.HEAT
          )



--
View this message in context: http://r.789695.n4.nabble.com/lattice-levelplot-axis-ticks-labels-tp4523198p4523198.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list