[R] Add an arrow to a plot
Joshua Wiley
jwiley.psych at gmail.com
Wed Jul 28 01:16:50 CEST 2010
Hi,
Here are two options. I would colour the last point differently, or
make it a different shape rather than using an arrow, but its your
choice.
x <- 1:10
y <- 1:10
#With an arrow
plot(x, y)
arrows(x0 = x[length(x)], y0 = y[length(y)] - 1,
x1 = x[length(x)], y1 = y[length(y)] - .5)
#Overwriting the point with an 'x'
#note this is controlled by the pch = 4 argument
plot(x, y)
points(x = x[length(x)], y = y[length(y)],
pch = 4, cex = 1.5, col = "blue")
see ?arrows ?plot ?points for documentation.
Cheers,
Josh
On Tue, Jul 27, 2010 at 2:06 PM, Trying To learn again
<tryingtolearnagain at gmail.com> wrote:
> Hi I want to plot an x,y plot something like an scatter plot.
>
> I always have the same doubt, were is the last point of my file?
>
> Imagine it is a time series so I want the last point to indicate with an
> arrow (but athomatically if posible).
>
> Someone knows if it is posible?
>
> Could it be posible to add additional arrows (with a small square with
> text?)
>
> I hope you can comprehead me?
>
> I suppose you will say: An arrow? Which width?size? I first need to see how
> it looks and if it is posible.
>
> Many thanks in advance¡¡¡
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list