File: compPlot.R

package info (click to toggle)
r-cran-misctools 0.6-30-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 368 kB
  • sloc: sh: 13; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,159 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
compPlot <- function( x, y, lim = NULL, ... ) {

   xyRange <- range( x, y, na.rm = TRUE, finite = TRUE )

   if( is.null( lim ) ) {
      lim <- xyRange
   } else {
      if( length( lim ) != 2 ) {
         stop( "argument 'lim' must be a vector of two elements" )
      }
      if( is.na( lim[1] ) ) {
         lim[1] <- xyRange[1]
      }
      if( is.na( lim[2] ) ) {
         lim[2] <- xyRange[2]
      }
      if( lim[1] >= lim[2] ) {
         stop( "the first element of argument 'lim' must be smaller",
            " than the second element" )
      }
      if( lim[1] > xyRange[1] |  lim[2] < xyRange[2] ) {
         warning( "some data points are outside the print area" )
      }
   }
   
   # code taken from plot.default()
   xlabel <- deparse(substitute(x))
   ylabel <- deparse(substitute(y))

   argList <- list( ... )
   
   argList$x <- x
   argList$y <- y
   argList$xlim <- lim
   argList$ylim <- lim
   if( ! "xlab" %in% names (argList) ) {
      argList$xlab <- xlabel 
   }
   if( ! "ylab" %in% names (argList) ) {
      argList$ylab <- ylabel 
   }
   
   do.call( plot.default, argList )

   abline( 0, 1 )

   invisible( xyRange )
}