Group Abstract Group Abstract

Message Boards Message Boards

2
|
7.4K Views
|
6 Replies
|
8 Total Likes
View groups...
Share
Share this post:

Use vertex names as VertexShapes, or equivalent?

Posted 4 years ago
POSTED BY: Richard Frost
6 Replies
Posted 4 years ago

Hi Richard,

The arrowheads overlap the frame around the labels. To avoid that and have more control over the size you can use a VertexShapeFunction.

vsf[width_, fontSize_][pos_, label_, _] := 
 Inset[Framed[
   Pane[Style[label, fontSize, TextAlignment -> Left], UpTo[width]], 
   Background -> LightYellow, RoundingRadius -> 5], pos]

Graph[edges,
 BaseStyle -> Arrowheads[Medium],
 EdgeStyle -> Black,
 VertexShapeFunction -> vsf[100, 12],
 VertexStyle -> Black,
 GraphLayout -> "SpringEmbedding",
 ImageSize -> Large,
 PerformanceGoal -> "Quality"]

enter image description here

POSTED BY: Rohit Namjoshi

You can try adjusting VertexSize:

Graph[edges, VertexShape -> vertexLabels, VertexSize -> Scaled[.4], 
 VertexStyle -> Black]
POSTED BY: Gianluca Gorni

Rohit ... thank you so much, this is great. I embellished by giving dashed borders to the datasets and switching to digraph layout.

programNames = suitedata[[;; , 1]];

vsf[width_, fontSize_][pos_, label_, _] := 
 Inset[Framed[
   Pane[Style[label, fontSize, TextAlignment -> Left], UpTo[width]], 
   Background -> LightYellow, RoundingRadius -> 5, 
   FrameStyle -> 
    If[MemberQ[programNames, label], Dashing[{}], Dashed]], pos]

Graph[edges, BaseStyle -> Arrowheads[Medium], EdgeStyle -> Black, 
 VertexShapeFunction -> vsf[100, 12], VertexStyle -> Black, 
 GraphLayout -> "LayeredDigraphEmbedding", ImageSize -> Large, 
 PerformanceGoal -> "Quality"]

enter image description here

POSTED BY: Richard Frost

Alas there seems not to be a way to let mathematica understand the vertex size before calculating the positions. So when creating a nice vertex layout which is "large" the vertexes will overlap. At least except for using a larger image size I've not been able to get mathematica adjust the vertex positions relative to the vertex sizes. Anyone who knows how to do that please post!

POSTED BY: l van Veen

Thank you Gianluca :)

enter image description here

POSTED BY: Richard Frost
Posted 4 years ago
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard