SCM

SCM Repository

[latticeextra] Diff of /pkg/R/axis.grid.R
ViewVC logotype

Diff of /pkg/R/axis.grid.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 164, Sat Jul 31 11:34:36 2010 UTC revision 165, Sun Aug 1 12:55:44 2010 UTC
# Line 2  Line 2 
2    
3  axis.grid <-  axis.grid <-
4      function(side = c("top", "bottom", "left", "right"),      function(side = c("top", "bottom", "left", "right"),
5                 ticks = c("default", "yes", "no"),
6               scales, components, ..., line.col)               scales, components, ..., line.col)
7  {  {
8      side <- match.arg(side)      side <- match.arg(side)
9      if (is.list(components[[side]])) { ## not on right/top sides      ticks <- match.arg(ticks)
10          scales.tck <- switch(side,          scales.tck <- switch(side,
11                               left = , bottom = scales$tck[1],                               left = , bottom = scales$tck[1],
12                               right = , top = scales$tck[2])                               right = , top = scales$tck[2])
13          ## only draw major ticks (those corresponding to labels)          ## only draw major ticks (those corresponding to labels)
14          comps.major <- components          comps.major <- components
15          tck <- components[[side]]$ticks$tck      mycomps <- components[[side]]
16          lab <- as.character(components[[side]]$labels$labels)      if (is.list(mycomps)) {
17            lab <- as.character(mycomps$labels$labels)
18          if (any(lab != "")) {          if (any(lab != "")) {
19                tck <- mycomps$ticks$tck
20              if (any(tck * scales.tck != 0)) {              if (any(tck * scales.tck != 0)) {
21                  tck <- rep(tck, length = length(lab))                  tck <- rep(tck, length = length(lab))
22                  comps.major[[side]]$ticks$tck <- ifelse(lab == "", NA, tck)                  comps.major[[side]]$ticks$tck <- ifelse(lab == "", NA, tck)
23              }              }
24            }
25        } else {
26            ticks <- "no"
27        }
28              ## use axis.text for ticks because axis.line$col might be transparent              ## use axis.text for ticks because axis.line$col might be transparent
29              axis.text <- trellis.par.get("axis.text")              axis.text <- trellis.par.get("axis.text")
30              axis.default(side, scales = scales,      axis.default(side, scales = scales, ticks = ticks,
31                           components = comps.major, ...,                           components = comps.major, ...,
32                           line.col = axis.text$col)                           line.col = axis.text$col)
         }  
     }  
33      ## now draw grid lines corresponding to axis ticks.      ## now draw grid lines corresponding to axis ticks.
34      ## can only do this with the bottom and right sides;      ## can only do this with the bottom and right sides;
35      ## otherwise the strip viewports are current, not panel.      ## otherwise the strip viewports are current, not panel.
# Line 34  Line 39 
39          return()          return()
40      ref.line <- trellis.par.get("reference.line")      ref.line <- trellis.par.get("reference.line")
41      if (side == "bottom") {      if (side == "bottom") {
42          comp.list <- components[["bottom"]]          tck <- abs(mycomps$ticks$tck)
43          tck <- abs(comp.list$ticks$tck)          panel.refline(v = mycomps$ticks$at,
         panel.refline(v = comp.list$ticks$at,  
44                        lwd = ref.line$lwd * tck,                        lwd = ref.line$lwd * tck,
45                        alpha = ref.line$alpha * tck / max(tck, na.rm = TRUE))                        alpha = ref.line$alpha * tck / max(tck, na.rm = TRUE))
46      }      }
47      if (side == "right") {      if (side == "right") {
48          comp.list <- components[["left"]] ## "left" is main component          if (!is.list(mycomps))
49          tck <- abs(comp.list$ticks$tck)              mycomps <- components[["left"]]
50          panel.refline(h = comp.list$ticks$at,          tck <- abs(mycomps$ticks$tck)
51            panel.refline(h = mycomps$ticks$at,
52                        lwd = ref.line$lwd * tck,                        lwd = ref.line$lwd * tck,
53                        alpha = ref.line$alpha * tck / max(tck, na.rm = TRUE))                        alpha = ref.line$alpha * tck / max(tck, na.rm = TRUE))
54      }      }

Legend:
Removed from v.164  
changed lines
  Added in v.165

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge