Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to make a TreeGraph[] that has as labels for vertices both text and Tooltip. The text displays all the time, when the TreeGraph is plotted, and in addition, when the mouse moves over the vertex, another text shows up using Tooltip (may be below the static text, but I'll worry about this later). This Tooltip text will contain more information about the node.

Right now, I can do each one of the above separately but can't figure how to combine them.

I'll show my attempts below. This is all using V9

Tooltip shows up when mouse on vertex

TreeGraph[{1, 2, 3}, {1 -> 2, 1 -> 3},
 VertexLabels -> {"Name", 3 -> Placed["equation 1", Tooltip]}, 
 ImagePadding -> 20]

enter image description here

standard vertex label

TreeGraph[{1, 2, 3}, {1 -> 2, 1 -> 3},
 VertexLabels -> {"Name"}, ImagePadding -> 20]

Mathematica graphics

Attempts to combine them

I noticed that it says in the help that any expression can be used as label: Mathematica graphics

attempt 1

Since any expression can be used as label, then I tried Column

TreeGraph[{1, 2, 3}, {1 -> 2, 1 -> 3},
 VertexLabels -> {"Name", 
   3 -> Column[{"3", Placed["equation 1", Tooltip]}]}, 
 ImagePadding -> 20]

Which does not work. Mathematica graphics

attempt 2

TreeGraph[{1, 2, 3}, {1 -> 2, 1 -> 3},
 VertexLabels -> {"Name", 
   3 -> Labeled[Placed["equation 1", Tooltip], "3"]}, 
 ImagePadding -> 20]

Mathematica graphics

attempt3

The strange thing is that one can add a button that changes the color of the node and speaks when clicked and also add a Tooltip at the same time, but so hard to add a text in addition to Tooltip

TreeGraph[{1, 2, Button[Style[3, Red], Speak["Vertex 3"]]}, {1 -> 2, 
  1 -> 3}, VertexLabels -> {"Name", 
   3 -> Placed["equation 1", Tooltip]}, ImagePadding -> 20]

Mathematica graphics Tried maybe another 10 different ways, too boring to show. So I gave up. I am a newbie in using Graphs in Mathematica, only today I started looking at them.

Question How make a label for Vertex and also show Toolip when mouse is on Vertex?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Tooltip appears to achieve what you are looking for.

TreeGraph[{1, 2, 3}, {1 -> 2, 1 -> 3}, 
VertexLabels -> {"Name", 3 -> Tooltip["3", "Equation 1"]}, ImagePadding -> 20]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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