matplot
Ben Bolker
ben@eno.Princeton.EDU
Fri, 16 Jan 1998 18:35:28 -0500 (EST)
matplot doesn't seem to pass through options like lwd, cex, etc.
quite the way I'd like. I've thought of two ways to fix this, I don't
know which is better.
The first is to treat lwd, cex, etc., exactly like the other options
(col, lty ...) -- (these diffs are long, skip down two pages if you want
to see the other way)
*** matplot.orig Tue Jan 13 18:17:54 1998
--- matplot.new2 Tue Jan 13 18:16:49 1998
***************
*** 1,12 ****
###---- As S (just 'better' ...)
! matpoints <- function(x, y, lty=1:5, pch=NULL, col=1:6, ...)
matplot(x=x, y=y, type = 'p', lty=lty, pch=pch, col=col, add=TRUE, ...)
! matlines <- function(x, y, lty=1:5, pch=NULL, col=1:6, ...)
matplot(x=x, y=y, type = 'l', lty=lty, pch=pch, col=col, add=TRUE, ...)
matplot <- function(x, y, type="p",
! lty=1:5, pch=NULL, col=1:6,
xlab=NULL, ylab=NULL, xlim=NULL, ylim=NULL,
..., add= FALSE, verbose = FALSE)
{
--- 1,12 ----
###---- As S (just 'better' ...)
! matpoints <- function(x, y, lty=1:5, pch=NULL, col=1:6, cex=1, ...)
matplot(x=x, y=y, type = 'p', lty=lty, pch=pch, col=col, add=TRUE, ...)
! matlines <- function(x, y, lty=1:5, pch=NULL, col=1:6, lwd=1, ...)
matplot(x=x, y=y, type = 'l', lty=lty, pch=pch, col=col, add=TRUE, ...)
matplot <- function(x, y, type="p",
! lty=1:5, pch=NULL, col=1:6, cex=1, lwd=1,
xlab=NULL, ylab=NULL, xlim=NULL, ylim=NULL,
..., add= FALSE, verbose = FALSE)
{
***************
*** 61,66 ****
--- 61,68 ----
if(length(lty) < k) lty <- rep(lty, length= k)
if(length(pch) < k) pch <- rep(pch, length= k)
if(length(col) < k) col <- rep(col, length= k)
+ if(length(cex) < k) cex <- rep(col, length= k)
+ if(length(lwd) < k) lwd <- rep(col, length= k)
ii <- 1:k
if(!add) {
ii <- ii[-1]
***************
*** 71,78 ****
for (i in ii) {
tp <- type[i]
if(tp=='l' || tp=='b'|| tp=='o'|| tp=='h')
! lines(x[,i],y[,i], type=tp, lty=lty[i],pch=pch[i],col=col[i])
if(do.points && tp=='p')
! points(x[,i],y[,i], pch=pch[i], col=col[i])
}
}
--- 73,82 ----
for (i in ii) {
tp <- type[i]
if(tp=='l' || tp=='b'|| tp=='o'|| tp=='h')
! lines(x[,i],y[,i], type=tp, lty=lty[i],pch=pch[i],col=col[i],
! lwd=lwd[i])
if(do.points && tp=='p')
! points(x[,i],y[,i], pch=pch[i], col=col[i],
! cex=cex[i])
}
}
The second is to pass extra options through ... -- I don't know if this
breaks anything, it doesn't seem to for me (and it may be more general).
*** matplot.orig Tue Jan 13 18:17:54 1998
--- matplot.new Tue Jan 13 18:06:48 1998
***************
*** 71,78 ****
for (i in ii) {
tp <- type[i]
if(tp=='l' || tp=='b'|| tp=='o'|| tp=='h')
! lines(x[,i],y[,i], type=tp, lty=lty[i],pch=pch[i],col=col[i])
if(do.points && tp=='p')
! points(x[,i],y[,i], pch=pch[i], col=col[i])
}
}
--- 71,79 ----
for (i in ii) {
tp <- type[i]
if(tp=='l' || tp=='b'|| tp=='o'|| tp=='h')
! lines(x[,i],y[,i], type=tp, lty=lty[i],pch=pch[i],col=col[i],
! ...)
if(do.points && tp=='p')
! points(x[,i],y[,i], pch=pch[i], col=col[i], ...)
}
}
Benjamin Bolker Dep't of Ecology and Evolutionary Biology,
ben@eno.princeton.edu Princeton University
tel: (609) 258-6886, fax: (609) 258-1334
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._