Reputation: 2540
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.
Upvotes: 4
Views: 610
Reputation: 61056
imgs = ExampleData /@ ExampleData["TestImage"];
GraphPlot[{1 -> 4, 1 -> 5, 2 -> 3, 2 -> 4, 2 -> 5, 3 -> 4, 3 -> 5},
VertexRenderingFunction -> (Inset[Image[imgs[[#2]], ImageSize -> 100], #1] &)]
Edit
-- Infix notation joke removed --
Upvotes: 4
Reputation: 34873
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] &)]
?
Upvotes: 2