tags:

views:

134

answers:

1

Hi All

I am trying to use GraphPlot function to build a Graph, where each node is an image. I wanted to display the image as my vertex. Does anybody know how to do this?

I tried something like this:

GraphPlot[  Map[If[# > 2.0 , 0, 1] &,
 imgDistT, {2}],  
 VertexRenderingFunction -> (Inset[imgs[[#2]], #1, Center] &) ]

But this does not work. imgs is my list of images corresponding to each vertex number.

As a sanity check, if i do this:

GraphPlot[
 Map[If[# > 2.0 , 0, 1] &, imgDistT, {2}], 
 VertexRenderingFunction -> (Inset[Text[#2], #1, Center] &) ]

then that works and it shows me the vertex number at each node.

+1  A: 

Two possible issues:

  • It looks like your graph, Map[If[# > 2.0 , 0, 1] &, imgDistT, {2}], will contain zeroes and ones—but zeroes are invalid indices for the imgs array

  • The images may not appear properly due to scaling issues—for example, they might be really big only the white portion might be visible. Try specifying an explicit image size.

What is the output of

GraphPlot[Map[If[# > 2.0 , 0, 1] &, imgDistT, {2}],
 VertexRenderingFunction -> (Module[{tmp = 
       Inset[Image[imgs[[#2]], ImageSize -> 10], #1, Center]}, 
     Print[tmp]; tmp] &)]

?

andrew