[R] Drawing paths through a grid

baptiste auguie baptiste.auguie at googlemail.com
Fri Jun 18 07:41:28 CEST 2010


Hi,

Try this,

## create a 2D grid with random point sizes
d = expand.grid(x=1:10,y=1:10)
 d$size = runif(nrow(d), 1,5)

## create some random links
links= d[sample(seq(1,nrow(d)),20),]
links$id = sample(2:6, nrow(links),repl=T)

## plot
library(ggplot2)
ggplot(d, mapping=aes(x,y)) +
  geom_point(aes(size=size)) +  geom_line(data=links,aes(colour=id,group=id))


HTH,

baptiste

On 18 June 2010 03:32, Rex C. Eastbourne <rex.eastbourne at gmail.com> wrote:
> I would like to draw a set of points that are equally spaced in a 2-D
> grid. Then I would like to draw lines that illustrate different
> directed paths through subsets of points. Imagine that the points
> correspond to booths in a conference center, and I want to show the
> various paths people took to visit the booths (using color to
> highlight different types of paths). An example path might be: [(1,1),
> (1,3), (3, 3)].
>
> Note: I would like to also make the size of the points in the grid
> variable (they correspond to the sizes of the booth).
>
> Can anyone suggest a way to do this in R? (Or to suggest another
> software package.)
>
> Thanks,
> Rex
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list