<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction
Step1:  In this chapter, We want to introduce you to the wonderful world of graph visualization.
You probably have seen graphs that are visualized as hairballs.
Apart from communicating how complex the graph is,
hairballs don't really communicate much else.
As such, my goal by the end of this chapter is 
to introduce you to what I call rational graph visualization.
But before we can do that, let's first make sure we understand
how to use NetworkX's drawing facilities to draw graphs to the screen.
In a pinch, and for small graphs, it's very handy to have.
Hairballs
The node-link diagram is the canonical diagram we will see in publications.
Nodes are commonly drawn as circles, while edges are drawn s lines.
Node-link diagrams are common,
and there's a good reason for this
Step2:  Nodes more tightly connected with one another are clustered together. 
Initial node placement is done typically at random,
so really it's tough to deterministically generate the same figure.
If the network is small enough to visualize,
and the node labels are small enough to fit in a circle,
then you can use the with_labels=True argument
to bring some degree of informativeness to the drawing
Step3:  The downside to drawing graphs this way is that
large graphs end up looking like hairballs.
Can you imagine a graph with more than the 28 nodes that we have?
As you probably can imagine, the default nx.draw(G)
is probably not suitable for generating visual insights.
Matrix Plot
A different way that we can visualize a graph is by visualizing it in its matrix form.
The nodes are on the x- and y- axes, and a filled square represent an edge between the nodes.
We can draw a graph's matrix form conveniently by using nxviz.MatrixPlot
Step4:  What can you tell from the graph visualization?
A few things are immediately obvious
Step5:  The Arc Plot forms the basis of the next visualization,
the highly popular Circos plot.
Circos Plot
The Circos Plot was developed by Martin Krzywinski at the BC Cancer Research Center. The nxviz.CircosPlot takes inspiration from the original by joining the two ends of the Arc Plot into a circle. Likewise, we can colour and order nodes by node metadata
Step6:  Generally speaking, you can think of a Circos Plot as being
a more compact and aesthetically pleasing version of Arc Plots.
Hive Plot
The final plot we'll show is, Hive Plots.
<ASSISTANT_TASK:>
Python Code:
from IPython.display import YouTubeVideo
YouTubeVideo(id="v9HrR_AF5Zc", width="100%")
Explanation: Introduction
End of explanation
from nams import load_data as cf
import networkx as nx
import matplotlib.pyplot as plt
G = cf.load_seventh_grader_network()
nx.draw(G)
Explanation: In this chapter, We want to introduce you to the wonderful world of graph visualization.
You probably have seen graphs that are visualized as hairballs.
Apart from communicating how complex the graph is,
hairballs don't really communicate much else.
As such, my goal by the end of this chapter is 
to introduce you to what I call rational graph visualization.
But before we can do that, let's first make sure we understand
how to use NetworkX's drawing facilities to draw graphs to the screen.
In a pinch, and for small graphs, it's very handy to have.
Hairballs
The node-link diagram is the canonical diagram we will see in publications.
Nodes are commonly drawn as circles, while edges are drawn s lines.
Node-link diagrams are common,
and there's a good reason for this: it's convenient to draw!
In NetworkX, we can draw node-link diagrams using:
End of explanation
G.is_directed()
nx.draw(G, with_labels=True)
Explanation: Nodes more tightly connected with one another are clustered together. 
Initial node placement is done typically at random,
so really it's tough to deterministically generate the same figure.
If the network is small enough to visualize,
and the node labels are small enough to fit in a circle,
then you can use the with_labels=True argument
to bring some degree of informativeness to the drawing:
End of explanation
import nxviz as nv 
from nxviz import annotate
nv.matrix(G, group_by="gender", node_color_by="gender")
annotate.matrix_group(G, group_by="gender")
Explanation: The downside to drawing graphs this way is that
large graphs end up looking like hairballs.
Can you imagine a graph with more than the 28 nodes that we have?
As you probably can imagine, the default nx.draw(G)
is probably not suitable for generating visual insights.
Matrix Plot
A different way that we can visualize a graph is by visualizing it in its matrix form.
The nodes are on the x- and y- axes, and a filled square represent an edge between the nodes.
We can draw a graph's matrix form conveniently by using nxviz.MatrixPlot:
End of explanation
# a = ArcPlot(G, node_color='gender', node_grouping='gender')
nv.arc(G, node_color_by="gender", group_by="gender")
annotate.arc_group(G, group_by="gender")
Explanation: What can you tell from the graph visualization?
A few things are immediately obvious:
The diagonal is empty: no student voted for themselves as their favourite.
The matrix is asymmetric about the diagonal: this is a directed graph!
(An undirected graph would be symmetric about the diagonal.)
You might go on to suggest that there is some clustering happening,
but without applying a proper clustering algorithm on the adjacency matrix,
we would be hard-pressed to know for sure.
After all, we can simply re-order the node ordering along the axes
to produce a seemingly-random matrix.
Arc Plot
The Arc Plot is another rational graph visualization.
Here, we line up the nodes along a horizontal axis,
and draw arcs between nodes if they are connected by an edge.
We can also optionally group and colour them by some metadata.
In the case of this student graph,
we group and colour them by "gender".
End of explanation
nv.circos(G, group_by="gender", node_color_by="gender")
annotate.circos_group(G, group_by="gender")
Explanation: The Arc Plot forms the basis of the next visualization,
the highly popular Circos plot.
Circos Plot
The Circos Plot was developed by Martin Krzywinski at the BC Cancer Research Center. The nxviz.CircosPlot takes inspiration from the original by joining the two ends of the Arc Plot into a circle. Likewise, we can colour and order nodes by node metadata:
End of explanation
from nxviz import plots
import matplotlib.pyplot as plt 
nv.hive(G, group_by="gender", node_color_by="gender")
annotate.hive_group(G, group_by="gender")
Explanation: Generally speaking, you can think of a Circos Plot as being
a more compact and aesthetically pleasing version of Arc Plots.
Hive Plot
The final plot we'll show is, Hive Plots.
End of explanation
<END_TASK>