Axes Labeling in Bar Charts
edges = {1 <-> 2, 1 <-> 3, 2 <-> 4, 3 <-> 4, 4 <-> 5, 4 <-> 6,
5 <-> 6, 7 <-> 6, 6 <-> 8, 8 <-> 9, 8 <-> 10, 9 <-> e, 10 <-> e};
prc = PageRankCentrality[edges]
{0.0798,0.0778,0.0778,0.1426,0.0749,0.1457,0.04461,0.1131,0.08059,0.08059,0.08214}
ordering = Ordering @ prc;
GraphPropertyChart
GraphComputation`GraphPropertyChart
gives a layout that combines a pie chart of vertex properties with a graph of edges:
gpc = GraphComputation`GraphPropertyChart[
Graph[VertexList[edges][[ordering]], edges],
Automatic -> prc[[ordering]], EdgeStyle -> Directive[CapForm["Butt"], Thickness[.05]],
ChartStyle->"DarkRainbow"]
Click on a vertex to get the incident edges highlighted:
Or use the function explode
from this answer by Simon Woods to highlight incident edges for selected vertices:
explode[pc_, i_] := ReplacePart[pc, Position[pc, False][[i]] -> True]
explode[gpc, VertexIndex[g, #] & /@ {10,3, 6}]
Additional examples:
GraphComputation`GraphPropertyChart[Graph[VertexList[edges][[ordering]], edges],
Automatic -> prc[[ordering]],
ChartElementFunction -> ChartElementDataFunction["NoiseSector",
"AngularFrequency" -> 5, "RadialAmplitude" -> .2],
ChartLabels -> (Style[#, 16] & /@ VertexList[edges][[ordering]]), ChartStyle -> 63] /.
{False -> True , Text[x_, pos_] :> {FaceForm[White], Disk[pos, .7], Text[x, pos]}}
With a different ChartElementFunction
:
ChartElementFunction -> ChartElementDataFunction["TriangleWaveSector",
"AngularFrequency" -> 10, "RadialAmplitude" -> .5]
GraphComputation`GraphPropertyChart[Graph[edges],
Automatic -> ConstantArray[1, VertexCount[edges]],
EdgeStyle -> Directive[CapForm["Butt"], Thickness[.05]]]
bwc = BetweennessCentrality[Graph[edges]];
GraphComputation`GraphPropertyChart[
Graph[VertexList[edges][[Ordering[bwc]]], edges], Automatic -> Sort[bwc],
EdgeStyle -> Directive[CapForm["Butt"], Thickness[.05]]]
PieChart
PieChart[prc[[ordering]], ChartStyle -> "DarkRainbow",
SectorOrigin -> {{2 Pi, "Counterclockwise"}, 1},
ChartLabels -> Placed[Style[#, 16] & /@ VertexList[edges][[ordering]], "RadialCallout"]]
BarChart
BarChart[prc[[ordering]], ChartStyle -> "DarkRainbow",
ChartLabels -> VertexList[edges][[ordering]]]
Update: Combining BarChart
with Graph
to produce something similar to the output of GraphPropertyChart
:
gr1 = Graph[VertexList[edges][[ordering]], edges];
graph = SetProperty[gr1,
{ImageSize -> 500, GraphLayout -> {"LinearEmbedding", Method -> "SpectralOrdering"},
VertexCoordinates -> Thread[{Range[VertexCount@gr1], 0}]}];
bc = BarChart[20 prc[[ordering]],
ChartLabels -> Placed[Style[#, 20] & /@ VertexList[gr1], Top],
ChartStyle -> "DarkRainbow", BarSpacing -> .2, BarOrigin -> Top,
Axes -> False, PerformanceGoal -> "Speed", ImageSize -> 500];
Show[bc, graph]
data = SortBy[{VertexList[edges],PageRankCentrality[edges]}\[Transpose], N@*Last]
BarChart[BB, ChartStyle -> "DarkRainbow",ChartLabels -> First /@ data]
Use associations:
BarChart[
Sort@AssociationThread[VertexList[edges], PageRankCentrality[edges]],
ChartLabels -> Automatic
]