Earthquake_standardization (guebin)
Non-Euclidean geometry
- 1. Data
- 2. $f(x)$
- 3. Haversine Fomula 사용한 거리 정의
- 4. Definition of a weighted adjacency matrix $W$
- 5. The weight edge function with temporal edge $(v_t,v_{t+1})$
- 6. Definition of Graph Laplacian matrix
- 7. Eigendecomposition
- 8. Principal components Analysis
- 2004, $n=571$
- 2005, $n=533$
- 2006, $n=512$
- 2007, $n=608$
- 2008, $n=508$
- 2009, $n=517$
- 2010, $n=560$
- 2011, $n=712$
import tqdm
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import networkx as nx
import time
import warnings
warnings.simplefilter("ignore", np.ComplexWarning)
from haversine import haversine
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')
_df = df.assign(Year=list(map(lambda x: x.split('/')[-1], df.Date))).query('Year=="2011"').reset_index().iloc[:,1:]
N=len(_df)
f_true = np.array(_df.loc[:,"Magnitude"])
f=f_true
f@f ## SST
(f-np.mean(f))@(f-np.mean(f)) ## SSE
(f*0-np.mean(f))@(f*0-np.mean(f)) ## SSH
# lat = np.array(_df.Latitude)
# long = np.array(_df.Longitude)
# return haversine((lat[i],long[i]),(lat[j],long[j]))
locations = np.array(_df.iloc[:,[1,2]])
dist_matrix = np.zeros((N,N))
for i in range(N):
for j in range(i,N):
dist_matrix[i,j]=haversine(locations[i],locations[j])
dist_matrix = dist_matrix + dist_matrix.T
dist_matrix
$$W_{u,v}=\begin{cases}{exp(-\frac{[dist(u,v)]^2}{2\theta^2})} & \quad \text{if } dist(u,v) \leq κ \\ 0 & \quad \text{otherwise} \end{cases}$$
# return np.exp( -np.abs(dist(i,j))**2 / (2*theta**2) ) if dist(i,j) <= kappa else 0
theta,kappa = 50, 100000
W = np.exp( -(dist_matrix/theta)**2)
plt.hist(W.reshape(-1))
$$W_{u_r,v_s}=\begin{cases} {W_{u,v}} & \quad \text{ if } u,v \in V_t \\ W_{u,v} \odot \beta & \quad \text{if }u=v \text{ and } r=s-1 \\ 0 & \quad \text{otherwise} \end{cases}$$
# if _df.Year[i] == _df.Year[j]:
# return 1
# elif abs(int(_df.Year[i]) - int(_df.Year[j])) == 1:
# return b
# else:
# return 0
_df.groupby("Year").aggregate(len)
Nlst = _df.groupby("Year").aggregate(len).Date.tolist()
Nlst = [0]+np.cumsum(Nlst).tolist()
Nlst
beta =np.zeros((N,N))
beta
for i in range(len(Nlst)-1):
beta[Nlst[i]:Nlst[i+1],Nlst[i]:Nlst[i+1]]= 1
beta
W = W * beta
plt.imshow(W)
d = W.sum(axis=1)
D = np.diag(d)
plt.imshow(D-W)
L = np.diag(1/np.sqrt(d)) @ (D-W) @ np.diag(1/np.sqrt(d))
plt.plot(f)
plt.plot(L@f)
λ, Ψ = np.linalg.eigh(L)
Λ = np.diag(λ)
- $comp_k = f @ np.outer(Ψ[:,k], Ψ[:,k]) $
- $k = 1, 2, 3, n$
- $p = \sum_{1}^{n} comp_{1}^{2},\sum_{1}^{n} comp_{2}^{2},…,\sum_{1}^{n} comp_{n}^{2}$
- $p = \frac{p}{\sum(p)}$
n=600
plt.plot(f,'.')
plt.plot(Ψ[:,0:n]@Ψ[:,0:n].T@f,'x')
fhats=[Ψ[:,[i]]@Ψ[:,[i]].T@f for i in tqdm.tqdm(range(N))]
fhats=np.array(fhats)
powers=np.apply_along_axis(lambda x: np.sum(x**2), 1, fhats)
plt.plot(λ,powers)
thresh = 1
powers[powers>thresh].sum() / powers.sum()
sum(powers>thresh)
sum(powers>thresh) / N
fhats2=fhats.copy()
fhats2[np.where(powers<thresh)]=0
fhats2
plt.plot(f)
plt.plot(fhats2.sum(axis=0))
plt.plot(f)
plt.plot(fhats2[λ<0.1].sum(axis=0))
_df["low"] = fhats2[λ<0.1].sum(axis=0)
_df["high"] = fhats2[λ>=0.1].sum(axis=0)
_df["res"] = f-fhats2.sum(axis=0)
#!conda install -c conda-forge basemap -y
#!conda install conda -y
import os
import conda
conda_file_dir = conda.__file__
conda_dir = conda_file_dir.split('lib')[0]
proj_lib = os.path.join(os.path.join(conda_dir, 'share'), 'proj')
os.environ["PROJ_LIB"] = proj_lib
from mpl_toolkits.basemap import Basemap
m = Basemap(projection='cyl', resolution=None,
llcrnrlat=-90, urcrnrlat=90,
llcrnrlon=-180, urcrnrlon=180)
from itertools import chain
def draw_map(m, scale=0.2):
# draw a shaded-relief image
m.shadedrelief(scale=scale)
# lats and longs are returned as a dictionary
lats = m.drawparallels(np.linspace(-90, 90, 13))
lons = m.drawmeridians(np.linspace(-180, 180, 13))
# keys contain the plt.Line2D instances
lat_lines = chain(*(tup[1][0] for tup in lats.items()))
lon_lines = chain(*(tup[1][0] for tup in lons.items()))
all_lines = chain(lat_lines, lon_lines)
# cycle through these lines and set the desired style
for line in all_lines:
line.set(linestyle='-', alpha=0.3, color='w')
_G1 = nx.Graph(W[:len(_df.query('Year<="2011"')),:len(_df.query('Year<="2011"'))]-np.identity(len(_df.query('Year=="2011"'))))
_pos1 = nx.spring_layout(_G1,iterations=20)
m_pos1 = list(zip(_df.query('Year=="2011"').Longitude,_df.query('Year=="2011"').Latitude))
fig,ax = plt.subplots(figsize = (16,8))
draw_map(m)
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2011"').low,node_size = 10,cmap="Reds",ax=ax,alpha=1)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
fig,ax = plt.subplots(figsize = (16,8))
draw_map(m)
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2011"').high,node_size = 10,cmap="Reds",ax=ax,alpha=0.5)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
fig,ax = plt.subplots(figsize = (16,8))
draw_map(m)
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2011"').res,node_size = 10,cmap="Reds",ax=ax,alpha=1)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
_G1 = nx.Graph(_W[:len(_df.query('Year<="2004"')),:len(_df.query('Year<="2004"'))]-np.identity(len(_df.query('Year=="2004"'))))
_pos1 = nx.spring_layout(_G1,iterations=20)
m_pos1 = list(zip(_df.query('Year=="2004"').Longitude,_df.query('Year=="2004"').Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2004"').comp1,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2004"').comp2,node_size = 10,ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2004"').comp3,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2004"').comp4,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2004"').comp5,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2004"').comp6,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G1,m_pos1,node_color=_df.query('Year=="2004"').comp7,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
_G2 = nx.Graph(_W[len(_df.query('Year<="2004"')):len(_df.query('Year<="2005"')),len(_df.query('Year<="2004"')):len(_df.query('Year<="2005"'))]-np.identity(len(_df.query('Year=="2005"'))))
_pos2 = nx.spring_layout(_G2,iterations=20)
m_pos2 = list(zip(_df.query('Year=="2005"').Longitude,_df.query('Year=="2005"').Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G2,m_pos2,node_color=_df.query('Year=="2005"').comp1,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G2,m_pos2,node_color=_df.query('Year=="2005"').comp2,node_size = 10,ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G2,m_pos2,node_color=_df.query('Year=="2005"').comp3,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G2,m_pos2,node_color=_df.query('Year=="2005"').comp4,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G2,m_pos2,node_color=_df.query('Year=="2005"').comp5,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G2,m_pos2,node_color=_df.query('Year=="2005"').comp6,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G2,m_pos2,node_color=_df.query('Year=="2005"').comp7,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
_G3 = nx.Graph(_W[len(_df.query('Year<="2005"')):len(_df.query('Year<="2006"')),len(_df.query('Year<="2005"')):len(_df.query('Year<="2006"'))]-np.identity(len(_df.query('Year=="2006"'))))
_pos3 = nx.spring_layout(_G3,iterations=20)
m_pos3 = list(zip(_df.query('Year=="2006"').Longitude,_df.query('Year=="2006"').Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G3,m_pos3,node_color=_df.query('Year=="2006"').comp1,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G3,m_pos3,node_color=_df.query('Year=="2006"').comp2,node_size = 10,ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G3,m_pos3,node_color=_df.query('Year=="2006"').comp3,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G3,m_pos3,node_color=_df.query('Year=="2006"').comp4,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G3,m_pos3,node_color=_df.query('Year=="2006"').comp5,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G3,m_pos3,node_color=_df.query('Year=="2006"').comp6,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G3,m_pos3,node_color=_df.query('Year=="2006"').comp7,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
_G4 = nx.Graph(_W[len(_df.query('Year<="2006"')):len(_df.query('Year<="2007"')),len(_df.query('Year<="2006"')):len(_df.query('Year<="2007"'))]-np.identity(len(_df.query('Year=="2007"'))))
_pos4 = nx.spring_layout(_G4,iterations=20)
m_pos4 = list(zip(_df.query('Year=="2007"').Longitude,_df.query('Year=="2007"').Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G4,m_pos4,node_color=_df.query('Year=="2007"').comp1,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G4,m_pos4,node_color=_df.query('Year=="2007"').comp2,node_size = 10,ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G4,m_pos4,node_color=_df.query('Year=="2007"').comp3,node_size =10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G4,m_pos4,node_color=_df.query('Year=="2007"').comp4,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G4,m_pos4,node_color=_df.query('Year=="2007"').comp5,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G4,m_pos4,node_color=_df.query('Year=="2007"').comp6,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G4,m_pos4,node_color=_df.query('Year=="2007"').comp7,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
_G5 = nx.Graph(_W[len(_df.query('Year<="2007"')):len(_df.query('Year<="2008"')),len(_df.query('Year<="2007"')):len(_df.query('Year<="2008"'))]-np.identity(len(_df.query('Year=="2008"'))))
_pos5 = nx.spring_layout(_G5,iterations=20)
m_pos5 = list(zip(_df.query('Year=="2008"').Longitude,_df.query('Year=="2008"').Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G5,m_pos5,node_color=_df.query('Year=="2008"').comp1,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G5,m_pos5,node_color=_df.query('Year=="2008"').comp2,node_size = 10,ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G5,m_pos5,node_color=_df.query('Year=="2008"').comp3,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G5,m_pos5,node_color=_df.query('Year=="2008"').comp4,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G5,m_pos5,node_color=_df.query('Year=="2008"').comp5,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G5,m_pos5,node_color=_df.query('Year=="2008"').comp6,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G5,m_pos5,node_color=_df.query('Year=="2008"').comp7,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
_G6 = nx.Graph(_W[len(_df.query('Year<="2008"')):len(_df.query('Year<="2009"')),len(_df.query('Year<="2008"')):len(_df.query('Year<="2009"'))]-np.identity(len(_df.query('Year=="2009"'))))
_pos6 = nx.spring_layout(_G6,iterations=20)
m_pos6 = list(zip(_df.query('Year=="2009"').Longitude,_df.query('Year=="2009"').Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G6,m_pos6,node_color=_df.query('Year=="2009"').comp1,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G6,m_pos6,node_color=_df.query('Year=="2009"').comp2,node_size = 10,ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G6,m_pos6,node_color=_df.query('Year=="2009"').comp3,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G6,m_pos6,node_color=_df.query('Year=="2009"').comp4,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G6,m_pos6,node_color=_df.query('Year=="2009"').comp5,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G6,m_pos6,node_color=_df.query('Year=="2009"').comp6,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G6,m_pos6,node_color=_df.query('Year=="2009"').comp7,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
_G7 = nx.Graph(_W[len(_df.query('Year<="2009"')):len(_df.query('Year<="2010"')),len(_df.query('Year<="2009"')):len(_df.query('Year<="2010"'))]-np.identity(len(_df.query('Year=="2010"'))))
_pos7 = nx.spring_layout(_G7,iterations=20)
m_pos7 = list(zip(_df.query('Year=="2010"').Longitude,_df.query('Year=="2010"').Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G7,m_pos7,node_color=_df.query('Year=="2010"').comp1,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G7,m_pos7,node_color=_df.query('Year=="2010"').comp2,node_size = 10,ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G7,m_pos7,node_color=_df.query('Year=="2010"').comp3,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G7,m_pos7,node_color=_df.query('Year=="2010"').comp4,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G7,m_pos7,node_color=_df.query('Year=="2010"').comp5,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G7,m_pos7,node_color=_df.query('Year=="2010"').comp6,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G7,m_pos7,node_color=_df.query('Year=="2010"').comp7,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
_G8 = nx.Graph(_W[len(_df.query('Year<="2010"')):len(_df.query('Year<="2011"')),len(_df.query('Year<="2010"')):len(_df.query('Year<="2011"'))]-np.identity(len(_df.query('Year=="2011"'))))
_pos8 = nx.spring_layout(_G8,iterations=20)
m_pos8 = list(zip(_df.query('Year=="2011"').Longitude,_df.query('Year=="2011"').Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G8,m_pos8,node_color=_df.query('Year=="2011"').comp1,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G8,m_pos8,node_color=_df.query('Year=="2011"').comp2,node_size = 10,ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G8,m_pos8,node_color=_df.query('Year=="2011"').comp3,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G8,m_pos8,node_color=_df.query('Year=="2011"').comp4,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G8,m_pos8,node_color=_df.query('Year=="2011"').comp5,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G8,m_pos8,node_color=_df.query('Year=="2011"').comp6,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G8,m_pos8,node_color=_df.query('Year=="2011"').comp7,node_size = 10, ax=ax,cmap='bwr')
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
plt.show()