-
Notifications
You must be signed in to change notification settings - Fork 0
/
stability_panel_mdl2.m
342 lines (296 loc) · 9.18 KB
/
stability_panel_mdl2.m
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
% Drawing Model 2 combined stability diagram panel
% This code draws a panel including both S vs r double bifurcation
% diagram (stability diagram) and six single bifurcation diagrams for S and r values indicated
% by lines in the stability diagram (Figure S1)
% Sofija Markovic
% 9/4/2024
% Dependencies
% r_bifurcation_diagram_mdl2.m - draws bifurcation diagrams in Fig. S1 E and F
% r_bifurcation_diagram_log_mdl2.m - draws bifurcation diagram in Fig. S1 G, where H is on log scale
% s_bifurcation_diagram_log_small_r_mdl2.m - draws bifurcation diagram in Fig. S1 B
% s_bifurcation_diagram_log_mdl2.m - draws bifurcation diagram in Fig. S1 C
% s_bifurcation_diagram_log_large_r_mdl2.m - draws bifurcation diagram in Fig. S1 D
clear
% Set Figure Properties
% Stability diagram formatting:
line_label_fs = 18;
axis_fs = 22;
ax_label_fs = 32;
stability_S_line_col = [112,48,100]/255;
stability_r_line_col = [242, 170, 132]/255;
stability_main = [64, 64, 64]/255;
stability_fill = [127, 127, 127]/255;
r_s_lines_col = [89, 89, 89]/255;
stability_main_lw = 2;
stability_x_y_lw = 1;
% bifurcation diagrams r dijagram za S = 0.01:
axis_font = 16;
label_font = 20;
annot_font = 16;
colormap = [0,0.45,0.74;0.47,0.67,0.19;1,0,0;]; % 77, 190, 238; 10, 140, 105; 162, 20, 47
lw = 1.5;
% Include titles to bif_diags:
bd_title = false;
bd_annot = true;
bd_label = true;
% Type of panel:
% 1: 4x4
% 2: 8x7
% 3: 7x8
panel = 2;
switch panel
case 1
tiledlayout(4,4, "TileSpacing","tight")
case 2
tiledlayout(8,7,"TileSpacing","tight")
case 3
tiledlayout(7,8, "TileSpacing","tight")
otherwise
error('Please state panel as integer 1, 2 or 3')
end
% Calculations:
% set the values of H:
p1 = [2,3,0,0,-2,-1];
zero = roots(p1);
H = zero(2):0.00001:100;
% calculate S and r:
r = ((3*H.^4 - 1).*(1+H).^2)./(1+H.^4).^2;
s = (2*H.^5 +3*H.^4 -2*H -1)./((3*H.^4 - 1).*(1+H).^2);
% Define S and r vec for bif diags
s_vec = 0.0001:0.0001:0.4;
r_vec = 0.0001:0.0001:3;
% For fill function:
X = [0, r];
Y = [0, s];
% S vs r stability diagram
switch panel
case 1
nexttile(1,[3,3])
case 2
nexttile(1,[6,5])
case 3
nexttile(1,[5,6])
end
fill(X,Y,stability_fill, 'EdgeColor','none','FaceAlpha',0.6)
hold on
plot(r,s, Color=stability_main, LineWidth=stability_main_lw)
ax1 = gca;
ax1.FontSize = axis_fs;
ax1.TickLength = [0.06 0.105];
% s values for r bifurcation diagram:
yl1 = yline(0.33,'--', 'S = 0.33',Color=r_s_lines_col,LineWidth=stability_x_y_lw);
yl1.FontSize = line_label_fs;
yl2 = yline(0.2,'-', 'S = 0.2', Color=r_s_lines_col,LineWidth=stability_x_y_lw);
yl2.FontSize = line_label_fs;
yl3 = yline(0.07,':', 'S = 0.07', Color=r_s_lines_col,LineWidth=stability_x_y_lw);
yl3.FontSize = line_label_fs;
% r values for s bifurcation diagram:
xl1 = xline(2.8,'--', 'r = 2.8', Color=r_s_lines_col,LineWidth=stability_x_y_lw);
xl1.FontSize = line_label_fs;
xl2 = xline(1.5,'-', 'r = 1.5', Color=r_s_lines_col,LineWidth=stability_x_y_lw);
xl2.FontSize = line_label_fs;
xl3 = xline(0.1,':', 'r = 0.1', Color=r_s_lines_col,LineWidth=stability_x_y_lw);
xl3.FontSize = line_label_fs;
xlabel('r', 'FontSize',ax_label_fs)
ylabel('S','FontSize', ax_label_fs)
box("on")
xlim([0,3.5])
ylim([0,0.38])
yticks([0, 0.1, 0.2, 0.3])
xticks([0, 1, 2, 3])
if bd_label == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.065;
pos_x = max(xlim) - range_x*0.025;
text(pos_x,pos_y,'A', 'Horiz','right', 'Vert','bottom','FontSize', 25)
end
hold off
% r diagram for S = 0.33
switch panel
case 1
nexttile
otherwise
nexttile([2,2])
end
r_bifurcation_diagram_mdl2(r_vec, 0.33, axis_font, label_font, colormap,lw)
set(gca,'TickLength',[0.06 0.105]);
xlim([0,3])
ylim([0,1])
yticks([0, 0.5, 1])
xticks([0, 1, 2, 3])
if bd_title == true
title('S = 0.33')
end
if bd_annot == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = min(ylim) + range_y*0.05;
pos_x = max(xlim) - range_x*0.05;
text(pos_x, pos_y,'S = 0.33', 'Horiz','right', 'Vert','bottom','FontSize',annot_font)
end
if bd_label == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.175;
pos_x = min(xlim) + range_x*0.1;
text(pos_x, pos_y,'E', 'Horiz','right', 'Vert','bottom', 'FontSize',annot_font)
end
% r diagram for S = 0.2
switch panel
case 1
nexttile
otherwise
nexttile([2,2])
end
r_bifurcation_diagram_mdl2(r_vec, 0.2, axis_font, label_font, colormap,lw);
set(gca,'TickLength',[0.06 0.105])
xlim([0,3])
ylim([0,4])
yticks([0, 2, 4])
xticks([0, 1, 2, 3])
if bd_title == true
title('S = 0.2')
end
if bd_annot == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = min(ylim) + range_y*0.05;
pos_x = max(xlim) - range_x*0.05;
text(pos_x, pos_y,'S = 0.2', 'Horiz','right', 'Vert','bottom','FontSize',annot_font)
end
if bd_label == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.175;
pos_x = min(xlim) + range_x*0.1;
text(pos_x, pos_y,'F', 'Horiz','right', 'Vert','bottom', 'FontSize',annot_font)
end
ArrowDown = annotation('arrow','LineStyle','--','LineWidth',2);
ArrowDown.Parent = gca;
ArrowDown.X = [0.7,0.7];
ArrowDown.Y = [2.6 ,0.41];
ArrowUp = annotation('arrow','LineStyle','--','LineWidth',2);
ArrowUp.Parent = gca;
ArrowUp.X = [1.65,1.65];
ArrowUp.Y = [1.15 ,3.7];
% r diagram for S = 0.07
switch panel
case 1
nexttile
otherwise
nexttile([2,2])
end
r_bifurcation_diagram_log_mdl2(r_vec, 0.07, axis_font, label_font, colormap,lw);
set(gca,'TickLength',[0.06 0.105])
xlim([0,3])
ylim([-6,6])
yticks([-6, 0, 6])
xticks([0, 1, 2, 3])
if bd_title == true
title('S = 0.01')
end
if bd_annot == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = min(ylim) + range_y*0.05;
pos_x = max(xlim) - range_x*0.05;
text(pos_x, pos_y,'S = 0.07', 'Horiz','right', 'Vert','bottom','FontSize',annot_font)
end
if bd_label == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.175;
pos_x = min(xlim) + range_x*0.1;
text(pos_x, pos_y,'G', 'Horiz','right', 'Vert','bottom', 'FontSize',annot_font)
end
% S diagram for r = 0.1
switch panel
case 1
nexttile
otherwise
nexttile([2,2])
end
s_bifurcation_diagram_log_small_r_mdl2(s_vec, 0.1, axis_font, label_font, colormap,lw);
set(gca,'TickLength',[0.06 0.105])
xlim([0,0.4])
ylim([-4,8])
yticks([-4, 2, 8])
xticks([0, 0.2, 0.4])
if bd_title == true
title('r = 0.1')
end
if bd_annot == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.05;
pos_x = max(xlim) - range_x*0.05;
text(pos_x, pos_y,'r = 0.1', 'Horiz','right', 'Vert','top','FontSize',annot_font)
end
if bd_label == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.175;
pos_x = min(xlim) + range_x*0.1;
text(pos_x, pos_y,'B', 'Horiz','right', 'Vert','bottom', 'FontSize',annot_font)
end
% S diagram for r = 1.5
switch panel
case 1
nexttile
otherwise
nexttile([2,2])
end
s_bifurcation_diagram_log_mdl2(s_vec, 1.5, axis_font, label_font, colormap,lw);
set(gca,'TickLength',[0.06 0.105])
xlim([0,0.4])
ylim([-2, 8])
yticks([-2, 3, 8])
xticks([0, 0.2, 0.4])
if bd_title == true
title('r = 1.5')
end
if bd_annot == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.05;
pos_x = max(xlim) - range_x*0.05;
text(pos_x, pos_y,'r = 1.5', 'Horiz','right', 'Vert','top','FontSize',annot_font)
end
if bd_label == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.175;
pos_x = min(xlim) + range_x*0.1;
text(pos_x, pos_y,'C', 'Horiz','right', 'Vert','bottom', 'FontSize',annot_font)
end
% S diagram for r = 2.8
switch panel
case 1
nexttile
otherwise
nexttile([2,2])
end
s_bifurcation_diagram_log_large_r_mdl2(s_vec, 2.8, axis_font, label_font, colormap,lw);
set(gca,'TickLength',[0.06 0.105])
xlim([0,0.4])
ylim([-2, 8])
yticks([-2, 3, 8])
xticks([0, 0.2, 0.4])
if bd_title == true
title('r = 2.8')
end
if bd_annot == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.05;
pos_x = max(xlim) - range_x*0.05;
text(pos_x, pos_y,'r = 2.8', 'Horiz','right', 'Vert','top','FontSize',annot_font)
end
if bd_label == true
range_x = max(xlim) - min(xlim);
range_y = max(ylim) - min(ylim);
pos_y = max(ylim) - range_y*0.175;
pos_x = min(xlim) + range_x*0.1;
text(pos_x, pos_y,'D', 'Horiz','right', 'Vert','bottom', 'FontSize',annot_font)
end