0
$\begingroup$

I imported an image and used it as vertex labels to draw a graph. The problem is I cannot control the size of the image. So it looks like this.

enter image description here

Here's my code. VertexLabelStyle does not seem to do anything.

mafia = Import["mafioso.png"];
gnp = RandomGraph[{10, 12},
  VertexLabels -> Placed[mafia, Center],
  VertexStyle -> LightYellow, 
  VertexLabelStyle -> Directive[20],
  VertexSize -> 0.5,
  ImageSize -> Medium,
  ImageMargins -> 10,
  GraphLayout -> "CircularEmbedding",
  VertexShapeFunction -> "Circle",
  PerformanceGoal -> "Quality"
  ]
$\endgroup$
2
$\begingroup$

You can give your image an explicit size with Pane. I don't have your mafia png, so here's a waterskiing icon instead:

water = Pane[
    Entity["Icon","Waterskiing"]["Image"],
    20
]

enter image description here

Then, use this image in your graph:

SeedRandom[1];
gnp = RandomGraph[{10, 12},
  VertexLabels -> Placed[water, Center],
  VertexStyle -> LightYellow, 
  VertexLabelStyle -> Directive[20],
  VertexSize -> 0.5,
  ImageSize -> Medium,
  ImageMargins -> 10,
  GraphLayout -> "CircularEmbedding",
  VertexShapeFunction -> "Circle",
  PerformanceGoal -> "Quality"
]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.