I have an adjacency matrix that I want to clearly generate a graphical view (a directed graph) showing all the nodes and edges using Python-- I found a similar question that was solved in Matlab.
I was able to find a solution using Pandas
and Networkx
but there is a limitation that I could not solve.
See the following code I used to generate the graph in Jupyter Notebook
:
%matplotlib inline
import pandas as pd
import networkx as nx
import matplotlib
import matplotlib.pyplot as plt
mx = pd.read_csv('/Users/student/Desktop/matrix.csv', sep='\t')
G = nx.DiGraph(mx.values)
nx.draw_networks(G)
This is output graph:
Problem: the graph is too small and I cannot see all the nodes clearly because the x-axis and y-axis is limited to 1.0.
I am having difficulty writing the scripts that expands the range of the axes in this matplotlib graph? I also want to mention that DiGraph()
has ax
parameter that take Matplotlib Axes object
Could help me how to solve this problem?