# How to overlay a network graph onto an image?

Posted 10 years ago
7718 Views
|
4 Replies
|
2 Total Likes
|
 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?
4 Replies
Sort By:
Posted 10 years ago
 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, Cyan}],   VertexStyle -> Red, VertexSize -> Tiny,    Prolog -> {Raster[      ImageData[       Darker[ImageResize[        ExampleData[{"TestImage", "Mandrill"}], {200}], .5],       DataReversed -> True]]}, PlotRange -> {{0, 200}, {0, 200}}  ] Posted 10 years ago
 You can get two superposed graphs or images using the construction:Graphics[{Inset[picture1,{x1,y1}],Inset[picture2,{x2,y2}]}]then adjusting the xs and ys to move the pictures into the desired positions.
Posted 10 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 10 years ago
 Hi Sam, Check out the following tutorial from Wolframhttp://reference.wolfram.com/language/example/BuildFoodWebs.html