« View all new features in
Mathematica
9
◄
previous
|
next
►
New in
Mathematica
9
›
Legends
Highlight Relationships in a Network
Show the groups centered around three people at a family gathering.
In[1]:=
X
familygathering = ExampleData[{"NetworkGraph", "FamilyGathering"}]
Out[1]=
Highlight the connections to David, Linda, and Oscar in different colors.
In[2]:=
X
people = {"Linda", "David", "Oscar"};
In[3]:=
X
highlightedgraph = HighlightGraph[familygathering, MapIndexed[ Style[Subgraph[familygathering, # \[UndirectedEdge] _], Directive[AbsoluteThickness[5], ColorData[68][First[#2]]]] &, people], ImageSize -> 400, VertexLabelStyle -> Directive[18, GrayLevel[0.3]], GraphHighlightStyle -> "VertexDiamond"]
Out[3]=
Create a line legend that matches the correct style to each person and combine it with the highlighted network.
In[4]:=
X
legend = LineLegend[ Table[Directive[AbsoluteThickness[5], ColorData[68][i]], {i, 3}], people, LabelStyle -> {18, Bold, GrayLevel[0.3]}, LegendMarkerSize -> {35, 15}]
Out[4]=
Combine the legend with the graph.
In[5]:=
X
Legended[highlightedgraph, legend]
Out[5]=