Earthquake_real
Non-Euclidean geometry
- 1. 데이터 정의
- 2. 정의
- 3. 비유클리드 공간에서의 거리 정의
- 4. time 고려, 거리를 이용한 a weighted adjacency matrix 정의
- 5. 행렬을 이용한 차수 행렬 정의
- 6. Graph Laplacian matrix 정의
- 7. 고유값 분해
- 8. 주성분 분석
- 9. PCA
- 를 이용한 = 80, = 1000
- 를 이용한 = 90, = 1000
- 를 이용한 = 100, = 1000
- 패키지를 이용한 = 50000, = 100000
- 패키지를 이용한 = 75000, = 100000
- 패키지를 이용한 = 100000, = 100000
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import networkx as nx
import folium
from IPython.display import HTML
df=pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')
대지진 순위중 일부 추출
pd.read_html('https://ko.wikipedia.org/wiki/%EC%A7%80%EC%A7%84_%EB%AA%A9%EB%A1%9D',encoding='utf-8')[1].iloc[[2,3,8],:]
- t = Year
- x = Latitude
- y = Longitude
- f = Magnitude
_df = df.assign(Year=list(map(lambda x: x.split('/')[-1], df.Date))).query('Year>="2004" & Year<="2011"').reset_index().iloc[:,1:]
f = _df.loc[:,"Magnitude"]
V_2004 = np.array([_df.query('Year=="2004"').iloc[:,1:3]])
V_2004
V_2005 = np.array([_df.query('Year=="2005"').iloc[:,1:3]])
V_2005.shape
np.hstack([V_2004,V_2005])
def dist(i,j):
a1=abs(_df.Latitude[j] - _df.Latitude[i])
a2=abs(_df.Latitude[j] + _df.Latitude[i])
b1=abs(_df.Longitude[j] - _df.Longitude[i])
b2=abs(_df.Longitude[j] + _df.Longitude[i])
a= np.min([a1,a2])
b= np.min([b1,b2])
return np.sqrt(a**2+b**2)
def weight1(i,j,theta=80,kappa=1000, beta=1):
if i == j :
return beta
if i == j+1:
return beta
elif dist(i,j) <= kappa :
return np.exp( -np.abs(dist(i,j))**2 / (2*theta**2) )
else:
return 0
def weight2(i,j,theta=90,kappa=1000, beta=1):
if i == j :
return beta
if i == j+1:
return beta
elif dist(i,j) <= kappa :
return np.exp( -np.abs(dist(i,j))**2 / (2*theta**2) )
else:
return 0
def weight3(i,j,theta=100,kappa=1000, beta=1):
if i == j :
return beta
if i == j+1:
return beta
elif dist(i,j) <= kappa :
return np.exp( -np.abs(dist(i,j))**2 / (2*theta**2) )
else:
return 0
하버사인haversine 공식 사용
from haversine import haversine
def dist2(i,j):
return haversine((_df.Latitude[i],_df.Longitude[i]),(_df.Latitude[j],_df.Longitude[j]))
def weight4(i,j,theta=50000,kappa=100000):
if i == j :
return beta
if i == j+1:
return beta
elif dist2(i,j) <= kappa :
return np.exp( -np.abs(dist2(i,j))**2 / (2*theta**2) )
else:
return 0
def weight5(i,j,theta=75000,kappa=100000):
if i == j :
return beta
if i == j+1:
return beta
elif dist2(i,j) <= kappa :
return np.exp( -np.abs(dist2(i,j))**2 / (2*theta**2) )
else:
return 0
def weight6(i,j,theta=100000,kappa=100000):
if i == j :
return beta
if i == j+1:
return beta
elif dist2(i,j) <= kappa :
return np.exp( -np.abs(dist2(i,j))**2 / (2*theta**2) )
else:
return 0
W1 = np.array([[weight1(i,j) for i in range(len(_df.query('Year=="2004"')))] for j in range(len(_df.query('Year=="2004"')))])
W1
plt.hist(W.reshape(-1))
W2 = np.array([[weight2(i,j) for i in range(len(_df))] for j in range(len(_df))])
W3 = np.array([[weight3(i,j) for i in range(len(_df))] for j in range(len(_df))])
W4 = np.array([[weight4(i,j) for i in range(len(_df))] for j in range(len(_df))])
W5 = np.array([[weight5(i,j) for i in range(len(_df))] for j in range(len(_df))])
W6 = np.array([[weight6(i,j) for i in range(len(_df))] for j in range(len(_df))])
D1 = np.diag(W1.sum(axis=1))
D2 = np.diag(W2.sum(axis=1))
D3 = np.diag(W3.sum(axis=1))
D4 = np.diag(W4.sum(axis=1))
D5 = np.diag(W5.sum(axis=1))
D6 = np.diag(W6.sum(axis=1))
L1 = D1 - W1
L2 = D2 - W2
L3 = D3 - W3
L4 = D4 - W4
L5 = D5 - W5
L6 = D6 - W6
λ1, Ψ1 = np.linalg.eig(L1)
Λ1 = np.diag(λ1)
λ2, Ψ2 = np.linalg.eig(L2)
Λ2 = np.diag(λ2)
λ3, Ψ3 = np.linalg.eig(L3)
Λ3 = np.diag(λ3)
λ4, Ψ4 = np.linalg.eig(L4)
Λ4 = np.diag(λ4)
λ5, Ψ5 = np.linalg.eig(L5)
Λ5 = np.diag(λ5)
λ6, Ψ6 = np.linalg.eig(L6)
Λ6 = np.diag(λ6)
def p1(i):
return sum((f @ np.outer( Ψ1[:,i], Ψ1[:,i]))**2)
array_11 = np.array([p1(i) for i in range(1,len(_df))])
varprop1 = array_11/array_11.sum()
_index1 = pd.DataFrame({'index':range(1,len(_df)),'varprop':varprop1}).sort_values('varprop',ascending=False)
_indexlst1 = _index1.iloc[:25,0].tolist()
def p2(i):
return sum((f @ np.outer( Ψ2[:,i], Ψ2[:,i]))**2)
array_12 = np.array([p2(i) for i in range(1,len(_df))])
varprop12 = array_12/array_12.sum()
_index2 = pd.DataFrame({'index':range(1,len(_df)),'varprop':varprop2}).sort_values('varprop',ascending=False)
_indexlst2 = _index2.iloc[:25,0].tolist()
def p3(i):
return sum((f @ np.outer( Ψ3[:,i], Ψ3[:,i]))**2)
array_13 = np.array([p3(i) for i in range(1,len(_df))])
varprop3 = array_13/array_13.sum()
_index3 = pd.DataFrame({'index':range(1,len(_df)),'varprop':varprop3}).sort_values('varprop',ascending=False)
_indexlst3 = _index3.iloc[:25,0].tolist()
def p4(i):
return sum((f @ np.outer( Ψ4[:,i], Ψ4[:,i]))**2)
array_14 = np.array([p4(i) for i in range(1,len(_df))])
varprop4 = array_14/array_14.sum()
_index4 = pd.DataFrame({'index':range(1,len(_df)),'varprop':varprop4}).sort_values('varprop',ascending=False)
_indexlst4 = _index4.iloc[:25,0].tolist()
def p5(i):
return sum((f @ np.outer( Ψ5[:,i], Ψ5[:,i]))**2)
array_15 = np.array([p5(i) for i in range(1,len(_df))])
varprop5 = array_15/array_15.sum()
_index5 = pd.DataFrame({'index':range(1,len(_df)),'varprop':varprop5}).sort_values('varprop',ascending=False)
_indexlst5 = _index5.iloc[:25,0].tolist()
def p6(i):
return sum((f @ np.outer( Ψ6[:,i], Ψ6[:,i]))**2)
array_16 = np.array([p6(i) for i in range(1,len(_df))])
varprop6 = array_16/array_16.sum()
_index6 = pd.DataFrame({'index':range(1,len(_df)),'varprop':varprop6}).sort_values('varprop',ascending=False)
_indexlst6 = _index6.iloc[:25,0].tolist()
comp11 = f @ np.outer( Ψ1[:,0], Ψ1[:,0])
comp21 = f @ np.outer( Ψ1[:,_indexlst1[0]], Ψ1[:,_indexlst1[0]])
comp31 = f @ np.outer( Ψ1[:,_indexlst1[1]], Ψ1[:,_indexlst1[1]])
comp41 = f @ np.outer( Ψ1[:,_indexlst1[2]], Ψ1[:,_indexlst1[2]])
comp51 = f @ np.outer( Ψ1[:,_indexlst1[3]], Ψ1[:,_indexlst1[3]])
_df["comp1"] = comp11
_df["comp2"] = comp21
_df["comp3"] = comp31
_df["comp4"] = comp41
_df["comp5"] = comp51
comp12 = f @ np.outer( Ψ2[:,0], Ψ2[:,0])
comp22 = f @ np.outer( Ψ2[:,_indexlst2[0]], Ψ2[:,_indexlst2[0]])
comp32 = f @ np.outer( Ψ2[:,_indexlst2[1]], Ψ2[:,_indexlst2[1]])
comp42 = f @ np.outer( Ψ2[:,_indexlst2[2]], Ψ2[:,_indexlst2[2]])
comp52 = f @ np.outer( Ψ2[:,_indexlst2[3]], Ψ2[:,_indexlst2[3]])
_df["comp1"] = comp12
_df["comp2"] = comp22
_df["comp3"] = comp32
_df["comp4"] = comp42
_df["comp5"] = comp52
_G1 = nx.Graph(W1-np.identity(len(f)))
_pos1 = nx.spring_layout(_G1,iterations=20)
m_pos1 = list(zip(_df.Longitude,_df.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.comp1,node_size = abs(_df.comp1)*10, ax=ax)
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.comp2,node_size = np.abs(_df.comp2)*100,ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Japan Sanriku", xy=(141.81051675491926,39.138785036804705), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
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.comp3,node_size = np.abs(_df.comp3)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
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.comp4,node_size = np.abs(_df.comp4)*100, ax=ax)
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.comp5,node_size = abs(_df.comp5)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Chile Maule", xy=(-72.41179564292405,-35.301421198712724), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
_G2 = nx.Graph(W2-np.identity(len(f)))
_pos2 = nx.spring_layout(_G2,iterations=20)
m_pos2 = list(zip(_df.Longitude,_df.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.comp1,node_size = abs(_df.comp1)*10, ax=ax)
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.comp2,node_size = np.abs(_df.comp2)*100,ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
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.comp3,node_size = np.abs(_df.comp3)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
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.comp4,node_size = np.abs(_df.comp4)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Japan Sanriku", xy=(141.81051675491926,39.138785036804705), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
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.comp5,node_size = abs(_df.comp5)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Chile Maule", xy=(-72.41179564292405,-35.301421198712724), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
_G = nx.Graph(W-np.identity(len(f)))
_pos = nx.spring_layout(_G,iterations=20)
m_pos = list(zip(_df.Longitude,_df.Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp1,node_size = abs(_df.comp1)*10, ax=ax)
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(_G,m_pos,node_color=_df.comp2,node_size = np.abs(_df.comp2)*100,ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Chile Maule", xy=(-72.41179564292405,-35.301421198712724), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp3,node_size = np.abs(_df.comp3)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp4,node_size = np.abs(_df.comp4)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Japan Sanriku", xy=(141.81051675491926,39.138785036804705), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp5,node_size = abs(_df.comp5)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
_G = nx.Graph(W-np.identity(len(f)))
_pos = nx.spring_layout(_G,iterations=20)
m_pos = list(zip(_df.Longitude,_df.Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp1,node_size = abs(_df.comp1)*10, ax=ax)
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(_G,m_pos,node_color=_df.comp2,node_size = np.abs(_df.comp2)*100,ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Chile Maule", xy=(-72.41179564292405,-35.301421198712724), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp3,node_size = np.abs(_df.comp3)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Japan Sanriku", xy=(141.81051675491926,39.138785036804705), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp4,node_size = np.abs(_df.comp4)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp5,node_size = abs(_df.comp5)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
# ax.annotate("Tasman Sea", xy=(160.4313,-40.8581), xycoords="data",
# va="center", ha="center",
# bbox=dict(boxstyle="circle, pad=3", alpha = 0.1,fc="w",lw=1, ec='r'))
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
_G = nx.Graph(W-np.identity(len(f)))
_pos = nx.spring_layout(_G,iterations=20)
m_pos = list(zip(_df.Longitude,_df.Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp1,node_size = abs(_df.comp1)*10, ax=ax)
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(_G,m_pos,node_color=_df.comp2,node_size = np.abs(_df.comp2)*100,ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Japan Sanriku", xy=(141.81051675491926,39.138785036804705), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp3,node_size = np.abs(_df.comp3)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Chile Maule", xy=(-72.41179564292405,-35.301421198712724), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp4,node_size = np.abs(_df.comp4)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp5,node_size = abs(_df.comp5)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
# ax.annotate("Tasman Sea", xy=(160.4313,-40.8581), xycoords="data",
# va="center", ha="center",
# bbox=dict(boxstyle="circle, pad=3", alpha = 0.1,fc="w",lw=1, ec='r'))
ax.annotate("Japan Sanriku", xy=(141.81051675491926,39.138785036804705), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
_G = nx.Graph(W-np.identity(len(f)))
_pos = nx.spring_layout(_G,iterations=20)
m_pos = list(zip(_df.Longitude,_df.Latitude))
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp1,node_size = abs(_df.comp1)*10, ax=ax)
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(_G,m_pos,node_color=_df.comp2,node_size = np.abs(_df.comp2)*100,ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=3", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp3,node_size = np.abs(_df.comp3)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Japan Sanriku", xy=(141.81051675491926,39.138785036804705), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp4,node_size = np.abs(_df.comp4)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Chile Maule", xy=(-72.41179564292405,-35.301421198712724), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=5", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()
with plt.style.context('seaborn-dark'):
fig,ax = plt.subplots(figsize = (16,8))
nodes = nx.draw_networkx_nodes(_G,m_pos,node_color=_df.comp5,node_size = abs(_df.comp5)*100, ax=ax)
plt.colorbar(nodes)
plt.axis()
ax.set_axis_on()
ax.tick_params(left=True, bottom=True, labelleft=True, labelbottom=True)
ax.annotate("Indonesia Sumatra", xy=( 101.28817388446576,-0.26014368149947664), xycoords="data",
va="center", ha="center",
bbox=dict(boxstyle="circle, pad=3", alpha = 0.1,fc="w",lw=1, ec='r'))
plt.show()