How can I label particular vertices in GraphPlot? And have the arrows space out accordingly, for the width of the label?
I have Mathematica 7, but I think this question applies to all versions.
Edit: I posted the above graph so you can see label overlap might kill whatever information the graph is displaying.
For simplicity, lets do a mock graph:
Generate the Data:
data = #[[1]] -> #[[2]] & /@ Partition[RandomInteger[10, 100], 2]
Plot the Graph:
GraphPlot[data, EdgeRenderingFunction -> ({Red, {Arrowheads[Small], Arrow[#1, .07]}} &)]
Gives something like:
If I wanted to explicitly label "1" and "5", this is where I'm completely lost:
I'm happy with the ugly yellow boxes for now:
GraphPlot[data,EdgeRenderingFunction->({Red,{Arrowheads[Small],Arrow[#1,.07]}}&), VertexLabeling->True]
But you can see it can be problematic if I labeled every point in the first graph. I wish the VertexLabelingFunction
help pages was a bit more thorough, all it seem it do is some sort of rule based, rather than explicit labels. I'm thinking it'll be some VertexLabelingFunction -> (If[#1 == "1" || #1 == "5", Text[#1]])&
But that always gives me an error.
VertexRenderingFunction
andGraphRenderingFunction
between Mathematica 7 and 8. Do you prefer an answer for 7 or for 8? $\endgroup$VertexRenderingFunction
? $\endgroup$