Message Boards Message Boards

4 Replies
2 Total Likes
View groups...
Share this post:

How to overlay a network graph onto an image?

Posted 11 years ago
I have a graph, and I have an image. I would like to have it such that specific actors are on specific points on the image. I really have no idea where to start?
POSTED BY: sam slocum
4 Replies
If you're using Graph, then supply the VertexCoordinates -> {} to specify the coordinates of the vertices. Note that these must be supplied in the order of the vertex nodes, I think.
points = {{1, 2}, {2, -1}, {3, 1}}
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1},VertexLabels -> "Name"]
Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1}, VertexLabels -> "Name", VertexCoordinates -> points, Axes -> True]

To place the graph over an image, you can use Overlay. Or you can have fun with the Prolog option in Graph:
 points = {{100, 180}, {150, 150}, {170, 100}};
 g = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
    3 \[UndirectedEdge] 1}, VertexLabels -> "Name",
   VertexCoordinates -> points,
   EdgeStyle -> Directive[{AbsoluteThickness[5], Cyan}],
   VertexStyle -> Red, VertexSize -> Tiny,
   Prolog -> {Raster[
        ExampleData[{"TestImage", "Mandrill"}], {200}], .5],
      DataReversed -> True]]}, PlotRange -> {{0, 200}, {0, 200}}
POSTED BY: C ormullion
You can get two superposed graphs or images using the construction:
then adjusting the xs and ys to move the pictures into the desired positions.
POSTED BY: S M Blinder
Posted 11 years ago
I had seen that tutorial, but I am sort of trying to do the opposite of that. I want to overlay the graph onto the image, specifying certain ponts on the image to be certain actors in the graph.
POSTED BY: sam slocum
Posted 11 years ago
Hi Sam, Check out the following tutorial from Wolfram
POSTED BY: Diego Zviovich
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract