Historically, MMA has never handled label collisions well, but recently they added some improvements here via things like Callout
. I want to fix ImageSize but still see as much as possible (by tooltipping a minimal set of vertices).
Here's two examples of the problem:
Unfortunately, Callout
doesn't work in Graphics
but it does on ListPlot type functions... any ideas?
Here's a starting point (some problems: callouts don't look like nice tree vertices labeled in-place, changing imagesize does not update callouts, below 200 imagesize doesn't look good...)
t=Tree["[email protected]", {Tree["[email protected]", {Tree["[email protected]", None], Tree["[email protected]", None],
Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]",
{Tree["[email protected]", None], Tree["[email protected]", {Tree["[email protected]", None], Tree["[email protected]", None],
Tree["[email protected]", None], Tree["[email protected]", None]}], Tree["[email protected]",
{Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None],
Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None],
Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None]}],
Tree["[email protected]", {Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None],
Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None]}],
Tree["[email protected]", {Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None],
Tree["[email protected]", {Tree["[email protected]", None]}], Tree["[email protected]", None], Tree["[email protected]", None]}]}],
Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None],
Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None], Tree["[email protected]", None]}]}];
g = Graph@t;
vc = Association[(#[[2]] -> AnnotationValue[{g, #}, VertexCoordinates]) & /@
VertexList[g]];
vl = Association[#2 -> #1 & @@@ VertexList[g]];
ve = #1[[2]] -> #2[[2]] & @@@ EdgeList[g];
data = Values@Merge[{vc, vl}, Identity]; is = 300;
annotated = data /. {{a_, b_}, n_} :> Callout[{a, b}, n];
Slider[Dynamic[is], {100, 800}]
ListPlot[annotated, Axes -> None,
Prolog -> {LightGray, Line[List @@@ (ve /. vc)]}, ImageSize -> Dynamic[is]]
t = RandomInteger[#] -> # + 1 & /@ Range[0, 30];
Slider[Dynamic[is], {100, 1500}], Dynamic[is]}
{Slider[Dynamic[ar], {0.05, 0.5}], Dynamic[ar]}
Dynamic[g = TreeGraph[t, VertexSize -> is/1800, AspectRatio -> ar, EdgeStyle -> {Arrowheads[{is/130000}]}, VertexLabels -> Placed[Automatic, Center, Tooltip], ImageSize -> is]]
$\endgroup$