Network Visualization: Chinese Railway Transport from 1992 to 2011
This is part of the preliminary data analysis of a course project. Data is collected from the National Statistical Beureau of China and in the unit of thousand tons. In the beginning, I start with a comprehensive table called
data, where for each province there's a matrix of 20 by 31, i.e. transport to each province w.r.t. different years. Therefore, it's convenient to extract the actual transient matrix for each year by using the method
The most important one is
networkx in this project.
There're two functions,
draw_networkx_edges_with_arrows for directed edges drawing,
plot_network for whole networks drawing.
def draw_networkx_edges_with_arrows(G, pos, width, edge_color, alpha=0.5, ax=None):
Data Preparation and Plotting
As I mentioned in the beginning, here the transient matrices are extracted by
groupby. For further usage, we save then by specifying the parameter
plot_network to be
rail = data.ix[:,6:-1].fillna(0).astype(int).groupby(data.Year)
Key package here is
imageio. I've set the limit for maximum pixel to 1e10 in case there's any overflow due to large figures in the above steps.
Well, I have to say it looks gorgeous.