-
Notifications
You must be signed in to change notification settings - Fork 0
/
08_plot_lcbd_results.jl
207 lines (185 loc) · 5.58 KB
/
08_plot_lcbd_results.jl
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
#### Plot richness & LCBD results ####
# SAVE = true # to export figures
# CAN = true
include("A0_required.jl");
# Load LCBD results
include("scripts/x_load_lcbd_results.jl");
# Check results
S_all
lcbd_species_all
lcbd_networks_all
# Set coordinate limits for plots
lims = boundingbox(S_all["mean"])
## Richness plots
# Richness for mean only
begin
fig = background_map(; lims=lims)
sf = surface!(S_all["mean"]; colormap=:cividis, shading=false)
Colorbar(fig[1,2], sf; height=Relative(0.5), label="Expected Richness")
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "richness_mean.png"), fig)
end
# Richness variance for mean only
begin
fig = background_map(; lims=lims=lims)
sf = surface!(Sv; colormap=:cividis, shading=false)
Colorbar(fig[1,2], sf; height=Relative(0.5), label="Richness variance")
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "richness_var.png"), fig)
end
# Bivariate richness map
begin
fig = Figure()
g1 = fig[1:16, 1:4] = GridLayout()
g2 = fig[2:5, end] = GridLayout()
p1 = background_map(g1[1,1]; lims=lims)
sf = bivariatesurface!(p1, S_all["mean"], Sv; bv_pal_2...)
p2 = Axis(g2[1,1]; aspect=1, xlabel = "Expected richness", ylabel = "Richness variance")
l2 = bivariatelegend!(p2, S_all["mean"], Sv; bv_pal_2...)
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "richness_bivariate.png"), fig)
end
## LCBD plots
# Species LCBD
begin
fig = background_map(; lims=lims)
sf = surface!(lcbd_species_all["mean"]; colormap=:viridis, shading=false)
Colorbar(fig[1,2], sf; height=Relative(0.5), label="Relative species LCBD")
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "lcbd_mean_species.png"), fig)
end
# Network LCBD
begin
fig = background_map(; lims=lims)
sf = surface!(lcbd_networks_all["mean"]; colormap=:viridis, shading=false)
Colorbar(fig[1,2], sf; height=Relative(0.5), label="Relative network LCBD")
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "lcbd_mean_networks.png"), fig)
end
# Bivariate species-networks LCBD for mean only
begin
fig = Figure()
g1 = fig[1:16, 1:4] = GridLayout()
g2 = fig[2:5, end] = GridLayout()
p1 = background_map(g1[1,1]; lims=lims)
sf = bivariatesurface!(p1, lcbd_species_nan, lcbd_networks_all["mean"])
p2 = Axis(g2[1,1]; aspect = 1, xlabel = "Species LCBD", ylabel = "Network LCBD")
l2 = bivariatelegend!(p2, lcbd_species_nan, lcbd_networks_all["mean"])
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "lcbd_bivariate_mean.png"), fig)
end
## Sampling options
options = reshape(options, (2,2))
# titles = reshape(titles, (2,2))
titles = [
"A) Mean value" "C) Random value";
"B) Mean value + threshold" "D) Random value + threshold"
]
# All richness options
begin
layers_all = S_all
cbmin = mapreduce(minimum, min, values(layers_all))
cbmax = mapreduce(maximum, max, values(layers_all))
fig = Figure(; resolution=(1250,600))
for i in 1:2, j in 1:2
o = options[i,j]
l = layers_all[o]
t = titles[i,j]
p = background_map(fig[i,j]; title=t, titlealign=:left, lims=lims)
s = surface!(
fig[i,j], l; colormap=:cividis, colorrange=(cbmin, cbmax), shading=false
)
Colorbar(p[1,2], s; height=Relative(0.5), label="Expected Richness")
end
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "sampling_options", "richness_all.png"), fig)
end
# All species LCBD options
#= # returns NaNs
begin
layers_all = lcbd_species_all
cbmin = mapreduce(minimum, min, values(layers_all))
cbmax = mapreduce(maximum, max, values(layers_all))
fig = Figure()
for i in 1:2, j in 1:2
o = options[i,j]
l = layers_all[o]
t = titles[i,j]
hm = heatmap(fig[i,j], l; colorrange=(cbmin, cbmax), axis=(;title=t))
end
Colorbar(
fig[:,end+1];
height=Relative(0.5),
label="Relative species LCBD",
colorrange=(cbmin, cbmax)
)
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "sampling_options", "lcbd_species_all.png"), fig)
end
=#
# All networks LCBD options
# NO DATA FOR NOW
#=
begin
layers_all = lcbd_networks_all
cbmin = mapreduce(minimum, min, values(layers_all))
cbmax = mapreduce(maximum, max, values(layers_all))
fig = Figure()
for i in 1:2, j in 1:2
o = options[i,j]
l = layers_all[o]
t = titles[i,j]
hm = heatmap(fig[i,j], l; colorrange=(cbmin, cbmax), axis=(;title=t))
end
Colorbar(
fig[:,end+1];
height=Relative(0.5),
label="Relative species LCBD",
colorrange=(cbmin, cbmax)
)
fig
end
if (@isdefined SAVE) && SAVE == true
save(joinpath("figures", "sampling_options", "lcbd_networks_all.png"), fig)
end
# Bivariate species-networks LCBD
biv_plots = []
for (i, opt) in enumerate(options)
bp = bivariate(
lcbd_networks_all[opt], lcbd_species_all[opt], ws;
quantiles=true, bv_pal_4..., classes=3, title=titles[i]
)
bp = bivariatelegend!(
lcbd_networks_all[opt],
lcbd_species_all[opt];
classes=3,
inset=(1, bbox(0.80, 0.02, 0.13, 0.28, :top, :right)),
subplot=2,
xlab="Networks LCBD",
ylab="Species LCBD",
guidefontsize=7,
bv_pal_4...
)
push!(biv_plots, bp)
end
plot(biv_plots..., size = (900, 600))
if (@isdefined SAVE) && SAVE == true
savefig(joinpath("figures", "sampling_options", "lcbd_bivariate_all.png"))
end
=#