Plot Arrows with Angle and length

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Plot Arrows with Angle and length

julio cesar oliveira
Dears,

The arrows command uses the start and end coordinates of each vector, but I
have the starting coordinates, azimuth, and length.

So, There are package that plot this arrows?

Example:

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


Thanks,

Julio

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plot Arrows with Angle and length

S Ellison-2
> The arrows command uses the start and end coordinates of each vector, but
> I have the starting coordinates, azimuth, and length.
>
> So, There are package that plot this arrows?
>
> Example:
>
> > 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, length, ..., units=c("degrees", "radians")) {
        units <- match.arg(units)
        az.rad <- switch(units,
                degrees=azimuth*pi/180,
                radians=azimuth
        )
        arrows(x, y, x+cos(az.rad)*length, y+sin(az.rad)*length, ...)
}

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]]
>
> ______________________________________________
> [hidden email] 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}}

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plot Arrows with Angle and length

Bert Gunter-2
In reply to this post by julio cesar oliveira
It's just basic trig to convert.

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Mar 29, 2017 at 6:44 AM, julio cesar oliveira <[hidden email]> wrote:

> Dears,
>
> The arrows command uses the start and end coordinates of each vector, but I
> have the starting coordinates, azimuth, and length.
>
> So, There are package that plot this arrows?
>
> Example:
>
>> x<- c(1,2,4)
>> y<- c(2,3,5)
>> Azimuth<- c(45,90,180)
>> Length<- c(1,0.5,1)
>
>
> Thanks,
>
> Julio
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plot Arrows with Angle and length

R help mailing list-2
In reply to this post by julio cesar oliveira
II find using complex numbers makes for less typing with
this sort of thing.  Note the use of plot(asp=1,...) to force
equal scales on both axes so the angles are right.
(I think asp=1 should have been the default when plotting complex
numbers, but too late now.)

> azimuthToNative <- function(degreesClockwise) {
+     # convert degrees clockwise from north to
+     # radians counter-clockwise from east.
+     (90-degreesClockwise)/180*base::pi
+ }
> start <- complex(real=x, imaginary=y)
> end <- start + complex(modulus = Length, argument = azimuthToNative(Azimuth))
> plot(c(start, end), type="n", asp=1) # asp=1 => equal scaling on both axes
> arrows(Re(start),Im(start),Re(end),Im(end)) # no complex method for arrows
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Wed, Mar 29, 2017 at 6:44 AM, julio cesar oliveira <[hidden email]> wrote:

> Dears,
>
> The arrows command uses the start and end coordinates of each vector, but I
> have the starting coordinates, azimuth, and length.
>
> So, There are package that plot this arrows?
>
> Example:
>
>> x<- c(1,2,4)
>> y<- c(2,3,5)
>> Azimuth<- c(45,90,180)
>> Length<- c(1,0.5,1)
>
>
> Thanks,
>
> Julio
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plot Arrows with Angle and length

Jim Lemon-4
In reply to this post by julio cesar oliveira
Hi Julio,
Perhaps "vectorField" (plotrix) is what you are looking for.

Jim


On Thu, Mar 30, 2017 at 12:44 AM, julio cesar oliveira
<[hidden email]> wrote:

> Dears,
>
> The arrows command uses the start and end coordinates of each vector, but I
> have the starting coordinates, azimuth, and length.
>
> So, There are package that plot this arrows?
>
> Example:
>
>> x<- c(1,2,4)
>> y<- c(2,3,5)
>> Azimuth<- c(45,90,180)
>> Length<- c(1,0.5,1)
>
>
> Thanks,
>
> Julio
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plot Arrows with Angle and length

glsnow
In reply to this post by julio cesar oliveira
You can also look at the my.symbols and ms.arrows functions in the
TeachingDemos package.


On Wed, Mar 29, 2017 at 7:44 AM, julio cesar oliveira <[hidden email]> wrote:

> Dears,
>
> The arrows command uses the start and end coordinates of each vector, but I
> have the starting coordinates, azimuth, and length.
>
> So, There are package that plot this arrows?
>
> Example:
>
>> x<- c(1,2,4)
>> y<- c(2,3,5)
>> Azimuth<- c(45,90,180)
>> Length<- c(1,0.5,1)
>
>
> Thanks,
>
> Julio
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.
Loading...