2
$\begingroup$

Basically, I'm trying to make Mathematica give me a tree with names inside the rectangles like so: enter image description here

...while also having the properties of VertexLabels or Tooltip, which lets me place my mouse over the name in the rectangle to give me additional information. Using VertexLabels alone places the names outside the nodes, which I don't want. Nor do I want circles - they need to be rectangles. Tooltip alone doesn't seem to work for the nodes, only the edges. Any help will be much appreciated.

$\endgroup$
2
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$
    – bbgodfrey
    Commented Feb 3, 2015 at 16:07
  • $\begingroup$ Please replace the image in the question by the actually code according to the guidelines in meta1027. Doing so will encourage more people to consider your question. $\endgroup$
    – bbgodfrey
    Commented Feb 3, 2015 at 16:08

1 Answer 1

2
$\begingroup$
ttF = Tooltip[#, "The Iliad of Homer"] &;

Use "The Iliad of Homer" as the tooltip for the nodes and the edge:

TreePlot[{ttF[# -> #2] & @@ ttF /@ {Peleus, Achiles}},  VertexLabeling -> All]

enter image description here

Alternatively, (1) Use the syntax $\left\{\left\{v_i\to v_j,\text{lbl}_1\right\},\ldots \right\}$ instead of $\left\{v_i\to v_j,v_{2 i}\to v_{2 j},\ldots \right\}$ to specify the edges. (2) Use the option settings VertexLabeling -> All and EdgeLabeling -> Automatic. (3) Post-process the TreePlot output to change the Tooltip labels.

TreePlot[{{Peleus -> Achiles, ""}}, VertexLabeling -> All, EdgeLabeling -> Automatic] /. 
      Tooltip[v_, _] :> Tooltip[v, "The Iliad of Homer"]
(* same picture *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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