@@ -103,7 +103,6 @@ def plot_comparison_gini_pulses(dataset_1, dataset_2, title, legend_1, legend_2,
103103 dataset_1_local = pd .read_csv (f"{ dataset_1 } _subpop_gini.csv" , index_col = 0 )
104104 dataset_2_local = pd .read_csv (f"{ dataset_2 } _subpop_gini.csv" , index_col = 0 )
105105
106-
107106 line1 , = plt .plot (dataset_1_local .mean (axis = 1 ), color = 'xkcd:sky blue' , label = f"{ legend_1 } subpop avg" )
108107 line2 , = plt .plot (dataset_2_local .mean (axis = 1 ), color = 'tan' , label = f"{ legend_2 } subpop avg" )
109108 plt .fill_between (dataset_1_local .index , dataset_1_local .mean (axis = 1 ) - dataset_1_local .std (axis = 1 ), dataset_1_local .mean (axis = 1 ) + dataset_1_local .std (axis = 1 ), color = 'xkcd:sky blue' , alpha = 0.3 )
@@ -130,4 +129,34 @@ def plot_comparison_gini_pulses(dataset_1, dataset_2, title, legend_1, legend_2,
130129 plt .grid (linestyle = ':' , linewidth = 0.5 )
131130 plt .title (title )
132131
133- plt .savefig (output_file )
132+ plt .savefig (output_file )
133+
134+
135+ def plot_subpopulation_mean (dataset , subpop_id , output_file , number_of_pulses = 5 , length_of_pulses = 1 , settling_period = 99 ):
136+ # deme = pd.Series(dataset[dataset["Replicate"] == 0][f"{subpop_id}"])
137+ for replicate in dataset ["Replicate" ].unique ():
138+ if replicate == 0 :
139+ deme = pd .Series (dataset [dataset ["Replicate" ] == replicate ][f"{ subpop_id } " ])
140+
141+ deme = pd .concat ([deme , pd .Series (dataset [dataset ["Replicate" ] == replicate ][f"{ subpop_id } " ])], axis = 1 )
142+
143+ fig = plt .plot (deme .mean (axis = 1 ), color = "tab:orange" )
144+ std_plus = deme .mean (axis = 1 ) + deme .std (axis = 1 )
145+ std_minus = deme .mean (axis = 1 ) - deme .std (axis = 1 )
146+ # std_plus cannot be larger than 100 in the beginning (but values can as it can be below 0 and this is a symetric +/-!)
147+ std_plus [std_plus > 100 ] = 100
148+ std_minus [std_minus < 0 ] = 0
149+ plt .fill_between (deme .index , std_minus , std_plus , alpha = 0.3 , color = "tab:orange" )
150+ plt .ylabel ("Individuals with extra trait" )
151+ plt .xlabel ("Generations (x100)" )
152+ plt .ylim ([0 , 100 ])
153+ plt .grid (linestyle = ':' , linewidth = 0.5 )
154+ plt .title (f"Extra trait in subpopulation { subpop_id } " )
155+
156+ plt .axvline (500 , color = "black" , linestyle = '--' , ymax = 1 )
157+ for i in range (1 , number_of_pulses + 1 ):
158+ plt .axvline (500 + i * (length_of_pulses + settling_period ), color = "dimgrey" , linestyle = '--' , ymax = 1 )
159+
160+ plt .savefig (output_file )
161+
162+ return fig , deme
0 commit comments