# How to overlay a network graph onto an image?

**URL:** <https://community.wolfram.com/t/how-to-overlay-a-network-graph-onto-an-image/1377>\
**Category:** Questions\
**Tags:** mathematica, graphics-and-visualization, graphs-and-networks\
**Created:** [January 27, 2014, 6:59pm UTC](https://community.wolfram.com/t/how-to-overlay-a-network-graph-onto-an-image/1377 "2014-01-27T18:59:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuelslocum96](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@samuelslocum96](https://community.wolfram.com/u/samuelslocum96)\
**Post date:** [January 27, 2014, 6:59pm UTC](https://community.wolfram.com/t/how-to-overlay-a-network-graph-onto-an-image/1377/1 "2014-01-27T18:59:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dzviovich](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dzviovich/32/27395_2.png) [@dzviovich](https://community.wolfram.com/u/dzviovich)\
**Post date:** [January 27, 2014, 7:22pm UTC](https://community.wolfram.com/t/how-to-overlay-a-network-graph-onto-an-image/1377/2 "2014-01-27T19:22:08Z")

</div>

Hi Sam, Check out the following tutorial from Wolfram

[http://reference.wolfram.com/language/example/BuildFoodWebs.html](http://reference.wolfram.com/language/example/BuildFoodWebs.html)

---

<div class="post-metadata">

**Author:** ![samuelslocum96](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@samuelslocum96](https://community.wolfram.com/u/samuelslocum96)\
**Post date:** [January 27, 2014, 11:47pm UTC](https://community.wolfram.com/t/how-to-overlay-a-network-graph-onto-an-image/1377/3 "2014-01-27T23:47:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sblinder](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sblinder/32/17861_2.png) [@sblinder](https://community.wolfram.com/u/sblinder)\
**Post date:** [January 28, 2014, 4:17am UTC](https://community.wolfram.com/t/how-to-overlay-a-network-graph-onto-an-image/1377/4 "2014-01-28T04:17:24Z")

</div>

You can get two superposed graphs or images using the construction:

```auto
Graphics[{Inset[picture1,{x1,y1}],Inset[picture2,{x2,y2}]}]

```

then adjusting the xs and ys to move the pictures into the desired positions.

---

<div class="post-metadata">

**Author:** ![cormullion](https://avatars.discourse-cdn.com/v4/letter/c/8491ac/32.png) [@cormullion](https://community.wolfram.com/u/cormullion)\
**Post date:** [January 28, 2014, 9:09am UTC](https://community.wolfram.com/t/how-to-overlay-a-network-graph-onto-an-image/1377/5 "2014-01-28T09:09:33Z")

</div>

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.

```auto
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]

```

 ![ScreenShot2014-01-28at09.08.42.png](https://global.discourse-cdn.com/wolfram/original/2X/9/95e55dad10cc088db5a540a027358094a9d0aa83.png)

To place the graph over an image, you can use Overlay. Or you can have fun with the Prolog option in Graph:

```auto
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[
     ImageData[
      Darker[ImageResize[
        ExampleData[{"TestImage", "Mandrill"}], {200}], .5], 
      DataReversed -> True]]}, PlotRange -> {{0, 200}, {0, 200}}
  ]

```

 ![ScreenShot2014-01-28at09.28.56.png](https://global.discourse-cdn.com/wolfram/original/2X/1/10fe7cb670fd0d3e7f2e0731a449ff11c6d91902.png)
