[R] Arrowheads at line-ends

Dan Michael Olsen Heggø Dan.Heggo at student.uib.no
Mon Oct 2 14:51:05 CEST 2006


Hi,

I'm quite new to R and I'm trying to do a simple plot with two lines,  
one upper and one lower. The problem is that the lines are reaching  
limiting values at x=0 for the upper line and x=1 for the lower.  
Thus, they are undefined at that values. I would like to indicate  
that with arrowheads. So I want a arrowhead at the left end of the  
upper line and a one at the right end at the lower line. I've managed  
to do this "manually" by drawing them with arrows, but this solution  
appears too be quite inflexible.

So my question to the more experienced R-users out there is if there  
is a smarter way to do this? Is there, for instance, any graphing  
property that automaticly insert arrowheads?

Here's the code of my "manual" solution:

xA <- c(0.0000,0.0968,0.2340,0.4645,0.6115,0.8890,1.0000)
Va <- c(69.016,69.769,70.775,72.456,73.280,73.564,73.921)
Vb <- c(18.020,17.822,17.480,16.897,16.277,13.833,13.101)

plot(c(0,1), c(10,80),
	type="n",
	xlab=expression(x[aceton]),
	ylab="Partielt molart volum",
	bty="o",
	xaxs="i", yaxs="i",
	xaxp=c(0,1,10),
	yaxp=c(10,80,20),
	penel.first = grid(20,20,lty=1)
)
points(xA[2:7],Va[2:7], type="o", col="blue",pch=5,lend=1)
points(xA[1:6],Vb[1:6], type="o", col="darkgreen",pch=5)

arrows(xA[2],Va[2],xA[1],Va[1],col="blue")
arrows(xA[6],Vb[6],xA[7],Vb[7],col="darkgreen")



More information about the R-help mailing list