4

I am new to R and trying to figure out how to make a social network map of a system that I have data for.

I have managed to figure out most of what I want to do from the FAQ and tutorials, but I am stuck on two things.

  1. How do I make the canvas larger / the graph more spaced out? Right now it's way too squashed.

  2. At the moment the edge thickness is set based on the weight. The weights represent different statuses (8 = Active, 3 = Requested, 2 = Hidden, 1 = Blocked) and I would like to style the edges rather than change their thickness. In an ideal world, green for Active, green dashed for Requested, black for hidden and red for blocked. One potential problem is that the weights may not be the same in both directions (i.e. u53 could be hiding or blocking u114, but u114 isn't doing either to u53). I am not sure what to do about that :)

I have put some sample data and code at http://www.r-fiddle.org/#/fiddle?id=7a2Aiql2&version=3

EDIT: Updated fiddle with colors (thanks @Chris) at http://www.r-fiddle.org/#/fiddle?id=7a2Aiql2&version=5 - still haven't worked out how to make a bigger plot so there's room for it all!

Thanks!

1
  • In vector graphics everything is relative, so make the vertices smaller. If you are using non-vector stuff, e.g. PNG, just create a bigger PNG. See ?png Jul 15, 2015 at 13:23

1 Answer 1

7
  1. You can change the values for the ylim and xlim arguments to plot.igraph (and perhaps also the asp argument). If none of those works, then you may have to give the vertices x and y attributes to space them out.
  2. To color edges based on weight, you would do e.g.

    E(g)$color[E(g)$weight == 8] <- 'green'
    E(g)$lty[E(g)$weight == 8] <- 1
    E(g)$color[E(g)$weight == 3] <- 'green'
    E(g)$lty[E(g)$weight == 3] <- 2
    

And so on. The rest of your question is more up to your personal preference.

1
  • Thanks - this answers the color question. Changing xlim/ylim and asp helped a bit (although I didn't really understand what I was doing), but really I need to make the canvas bigger so there's more room for things to be spaced out. Updated fiddle at r-fiddle.org/#/fiddle?id=7a2Aiql2&version=5 Jul 14, 2015 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.