-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotFigure3-clustering.py
166 lines (131 loc) · 6.94 KB
/
plotFigure3-clustering.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# -*- coding: utf-8 -*-
import glob, os, sys
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.style as style
import seaborn as sns
import pandas as pd
from collections import OrderedDict
from matplotlib.colors import LogNorm
fileDirectory = "/home/karpouzi/Research/Eukaryote-mountdir/"
sns.set_context("paper")
wList = [0.0,4.0]
colorList=["b","m","y","r"]
filePaths = []
for w in wList:
filePath = fileDirectory + "REPS_AGRE_T_4000.0_dtp_0.1_n_40.0_a0_0.2_d0_0.0_ksi_1.2_sar_0.25_a_0.0_w_" + str(w) + "_Tag_0.1_Tab_50.0_Tr_5.0_Td_50.0_d_1.0_dtsave_1.0.csv"
filePaths.append(filePath)
fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(6.5, 4.5))
#space foor w=0 before transition
vec0=np.arange(0,220,30)
vec2=np.arange(950,1150,30)
# plot for w=0
dataFrame = pd.read_csv(filePaths[0], sep=" ", header=0, usecols = ["t","maxSize","nFrag"], nrows=8000)
dataFrame = dataFrame[dataFrame['t']<1100]
dataFrame['t'] = np.around(dataFrame['t'], decimals=0)
df0=dataFrame.loc[dataFrame["t"].isin(vec0)]
df00=df0.groupby(['t']).mean(numeric_only=True)
df1=dataFrame.loc[(dataFrame["t"]>220)&(dataFrame["t"]<950)]
df11=df1.groupby(['t']).mean(numeric_only=True)
df2=dataFrame.loc[dataFrame["t"].isin(vec2)]
df22=df2.groupby(['t']).mean(numeric_only=True)
df=dataFrame.groupby(['t']).mean(numeric_only=True)
dfLegend = df
dfLegend['maxSize'] = np.around(dfLegend['maxSize'], decimals=2)
print(dfLegend["maxSize"])
dfLegend = dfLegend.loc[(dfLegend["maxSize"]==0.5)]
print(dfLegend["maxSize"])
sns.set_palette("colorblind")
sns.set_color_codes("colorblind")
sns.scatterplot(x="t",y="nFrag",size="maxSize", color='w', sizes=(dfLegend['maxSize'].min()*200, dfLegend['maxSize'].max()*200), ax=axs[0,1], data=dfLegend)
sns.scatterplot(x="t",y="nFrag",size="maxSize", color='w', sizes=(df['maxSize'].min()*200, df['maxSize'].max()*200), ax=axs[0,1], data=df, legend=False)
sns.scatterplot(x="t",y="nFrag",size="maxSize", color='b', sizes=(df00['maxSize'].min()*200, df00['maxSize'].max()*200), ax=axs[0,1], data=df00,legend=False)
sns.scatterplot(x="t",y="nFrag",size="maxSize", color='b', sizes=(df11['maxSize'].min()*200, df11['maxSize'].max()*200), ax=axs[0,1], data=df11,legend=False, edgecolor='face')
sns.scatterplot(x="t",y="nFrag",size="maxSize", color='b', sizes=(df22['maxSize'].min()*200, df22['maxSize'].max()*200), ax=axs[0,1], data=df22,legend=False)
#space foor w=4.0
vec0=np.arange(0,1150,30)
# plot for w=0
dataFrame = pd.read_csv(filePaths[1], sep=" ", header=0, usecols = ["t","maxSize","nFrag"], nrows=8000)
dataFrame = dataFrame[dataFrame['t']<1100]
dataFrame['t'] = np.around(dataFrame['t'], decimals=0)
df0=dataFrame.loc[dataFrame["t"].isin(vec0)]
df00=df0.groupby(['t']).mean(numeric_only=True)
sns.scatterplot(x="t",y="nFrag",size="maxSize", color='r', sizes=(df00['maxSize'].min()*200, df00['maxSize'].max()*200), ax=axs[1,1], data=df00,legend=False)
axs[0,1].annotate(r"$\omega=0$", xy=(970,140), size=10)
axs[1,1].annotate(r"$\omega=4$", xy=(970,140), size=10)
axs[0,1].set_title(r"$\bf{b}$"+" Fragmentation measures dynamics")
axs[0,1].set_ylim(-10,160)
axs[1,1].set_ylim(-10,160)
axs[0,1].set_xlim(-150,1200)
axs[1,1].set_xlim(-150,1200)
axs[0,1].legend(title="Frag. Size",loc='upper left')
axs[0,1].set_xlabel("")
axs[1,1].set_xlabel("Time")
axs[1,1].xaxis.labelpad = 5
axs[0,1].set_ylabel("Number of fragments")
axs[0,1].yaxis.labelpad = 5
axs[1,1].set_ylabel("Number of fragments")
axs[1,1].yaxis.labelpad = 5
dataFrameTheo = pd.read_csv("/home/karpouzi/Research/Eukaryote-mountdir/experimentA0W-040821.csv")
wList = [0.0,1.0,2.0,4.0]
dataFrameTheo['normalMax'] = dataFrameTheo['maxSize'].div(dataFrameTheo['N']*1600)
for ix, w in enumerate(wList):
sns.lineplot(x="N",y="maxSize", ax=axs[0,0], color = colorList[ix], linewidth=3.0 ,label = str(w), data=dataFrameTheo[dataFrameTheo['w']==w] )
sns.lineplot(x="N",y="nFrag", ax=axs[1,0], color = colorList[ix], linewidth=3.0 ,data=dataFrameTheo[dataFrameTheo['w']==w] )
axs[1,0].axvline(0.59,linewidth=4, color='k', alpha=0.4)
axs[0,0].axvline(0.59,linewidth=4, color='k', alpha=0.4)
axs[0,0].set_title(r"$\bf{a}$ Fragmentation measures")
axs[0,0].set_xlabel("")
axs[1,0].set_xlabel("Fraction of natural land")
axs[1,0].xaxis.labelpad = 5
axs[0,0].set_ylabel("Largest fragment size")
axs[0,0].yaxis.labelpad = 5
axs[1,0].set_ylabel("Number of fragments")
axs[1,0].yaxis.labelpad = 5
axs[0,0].invert_xaxis()
axs[1,0].invert_xaxis()
axs[0,0].legend(title = r'$\omega$')
plt.tight_layout()
plt.savefig('Figure3-clustering-revision.pdf', format='pdf', dpi = 1200, bbox_inches='tight')
plt.show()
# filePathextra = "/home/karpouzi/Research/Eukaryote-mountdir/REPS_AGRE_T_100.0_dtp_0.1_n_40.0_a0_0.35_d0_0.0_ksi_1.2_sar_0.25_a_0.0_w_0.0_Tag_0.1_Tab_50.0_Tr_5.0_Td_50.0_d_1.0_dtsave_0.01.csv"
# dfextra = pd.read_csv(filePathextra, sep=" ", header=0, usecols = ["t","N","maxSize","nFrag"])
# dfextra['N'] = np.around(dfextra['N'], decimals=2)
#
# sns.lineplot(x="N",y="maxSize", ax=axs[0], color = "tab:purple", data=dfextra )
# sns.lineplot(x="N",y="nFrag", ax=axs[1], color = "tab:purple", data=dfextra )
# for ix, file in enumerate(filePaths):
# print("begin import file " + str(ix) )
# dataFrame = pd.read_csv(file, sep=" ", header=0, usecols = ["t","N","maxSize","nFrag"], nrows = 12000)
# # dataFrame=dataFrame[(dataFrame['t']>1500) & (dataFrame['t']<3000)]
# dataFrame['t'] = np.around(dataFrame['t'], decimals=0)
# sns.lineplot(x="t",y="N", ax=axs[0], label = wList[ix], data=dataFrame)
# sns.lineplot(x="t",y="maxSize", ax=axs[1], label = wList[ix], data=dataFrame)
# # dataFrame['N'] = np.around(dataFrame['N'], decimals=2)
# print("import done")
#
# # dataFrame=dataFrame.iloc[:6000,:]
# print(dataFrame)
# # plot of connectance over time
# sns.lineplot(x="t",y="maxSize", ax=axs[0,0], label = wList[ix], data=dataFrame)
# sns.lineplot(x="t",y="nFrag", ax=axs[1,0], label = wList[ix], data=dataFrame)
# plot of connectance versus natural land
# sns.lineplot(x="N",y="maxSize", ax=axs[0], color = colorList[ix], data=dataFrameTheo[dataFrameTheo['w']==wList[ix]] )
# sns.lineplot(x="N",y="maxSize", ax=axs[0], color = colorList[ix], label = wList[ix], data=dataFrame)
# sns.lineplot(x="N",y="nFrag", ax=axs[1], color = colorList[ix], data=dataFrameTheo[dataFrameTheo['w']==wList[ix]] )
# sns.lineplot(x="N",y="nFrag", ax=axs[1], color = colorList[ix], label = wList[ix], data=dataFrame)
# aList = [0.25,0.05,0.1,0.15]
# colorList=["b","m","y","r"]
# filePaths = []
#
# for a in aList:
# filePath = fileDirectory + "REPS_AGRE_T_3000.0_dtp_0.1_n_40.0_a0_0.25_d0_0.0_ksi_1.2_sar_0.25_a_"+str(a)+"_w_0.0_Tag_0.1_Tab_50.0_Tr_5.0_Td_50.0_d_1.0_dtsave_1.0.csv"
# filePaths.append(filePath)
#
# fig, axs = plt.subplots(nrows=1, ncols=1)
#
# for ix, file in enumerate(filePaths):
# dataFrame = pd.read_csv(file, sep=" ", header=0, usecols = ["t","N"])
# dataFrame['t'] = np.around(dataFrame['t'], decimals=0)
# sns.lineplot(x="t",y="N", ax=axs, label = aList[ix], data=dataFrame)
#