[R] plotting functions with line width (lwd) as vectors

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue May 21 16:03:17 CEST 2002


Wolfram Fischer - Z/I/M <wolfram at fischer-zim.ch> writes:

> If I want to plot different widths of line segments or arrows
> I have to program loops to plot each line apartly. Is that
> right?
> 	n    <- 6
> 	x    <- 1:n
> 	y    <- rnorm(1:n)
> 	q    <- ( x %% 3 + 1 ) * 2
> 	plot( x, y, cex=q )
> 	for( i in 1:(n-1) ) lines( x[i:(i+1)], y[i:(i+1)], lwd=q[i], col=q[i] )
> 
> Would it not be possible to make plotting functions accept
> vectors of line widths (as they accept vectors of colors
> and vectors for cex)?
> 
> So you could say e.g.:
> 	plot( x, y, cex=q )
> 	lines( x, y, lwd=q, col=q )

Logically, a line like that is a single entity, and it is generally
plotted using some low-level polyline routine, so no.

However, notice that you can do 

plot(1:10,type="n")
segments(1:9,1:9,2:10,2:10,lwd=1:9)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list