[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-help
Subject:    Re: [R] Plot Arrows with Angle and length - correction
From:       S Ellison <S.Ellison () LGCGroup ! com>
Date:       2017-03-29 14:13:10
Message-ID: 1A8C1289955EF649A09086A153E26724056F16D276 () GBTEDVPEXCMB04 ! corp ! lgc-group ! com
[Download RAW message or body]

Apologies; 'length' is an arrows() argument. Use something else - see below.

> > x<- c(1,2,4)
> > y<- c(2,3,5)
> > Azimuth<- c(45,90,180)
> > Length<- c(1,0.5,1)

May be packages out there but if it's a quick fix you want, roll your own.

arrows.az <- function(x, y, azimuth, size, ..., units=c("degrees", "radians")) {
	#Using 'size' to avoid clash with arrows(..., length=...)
	units <- match.arg(units)
	az.rad <- switch(units,
		degrees=azimuth*pi/180,
		radians=azimuth
	)
	arrows(x, y, x+cos(az.rad)*size, y+sin(az.rad)*size, ...)
}

plot(0:6, 0:6, type="n")
arrows.az(x, y, Azimuth, Length)

"..." means you can pass all the other options to arrows()

S Ellison


> 
> 
> Thanks,
> 
> Julio
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic