Graph [] disables vertex labels in Mathematica

Graph[]tends to crop vertex labels in Mathematica. I am looking for a reliable workaround.

Example:

Graph[{1 -> 2, 2 -> 3, 3 -> 1}, VertexLabels -> "Name"]

Graph [] cuts off the label '2'

My current solution:

SetOptions[Graph, ImagePadding -> 12]

This is not reliable, because the value ImagePaddingmust be adjusted manually depending on the size of the label.

+5
source share
2 answers

Apparently, using the FullGraphicsobject Graphwill fix the clipping for display purposes due to interactivity.

The comment below Show[]also works and avoids changing graphics.

+2
source

Here are two possible workarounds.

. , , , 1.

:

Table[Graph[{1 -> 2, 2 -> 3, 3 -> 1}, VertexSize -> 0.3, 
    VertexLabels -> Table[i -> 
       Placed["vertex" <> ToString[i], p], {i, 3}],
    VertexShapeFunction -> "Square", PlotLabel -> p], 
 {p, {Left, Top, Right, Bottom, Center}}]

. [Edit: Center, , , , \n , , , .]

:

Graph[{1 -> 2, 2 -> 3, 3 -> 1}, VertexLabels -> Placed["Name", Tooltip]]

, .

+1

All Articles