-
Notifications
You must be signed in to change notification settings - Fork 0
/
visuals.jl
111 lines (97 loc) · 3.04 KB
/
visuals.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
using CairoMakie
using GLMakie
using Makie.Colors
using Plots
# get global extrema
extremas = map(extrema, metacommunity)
global_min = minimum(t -> first(t), extremas)
global_max = maximum(t -> last(t), extremas)
# these limits have to be shared by the maps and the colorbar
clims = (global_min, global_max)
species_col = fill("", species_richness)
for i in axes(species_col, 1)
if trophic_level[i] == 1
species_col[i] = "green"
elseif trophic_level[i] == 2
species_col[i] = "blue"
else
species_col[i] = "red"
end
end
# Some diagnostic plots
#burnin community
fig = Figure()
axs = [
Axis(fig[1, 1];
xlabel = "Environment value",
ylabel = "Abundance"),
Axis(fig[1, 2];
xlabel = "Environment value",
ylabel = "Abundance"),
Axis(fig[1, 3];
xlabel = "Environment value",
ylabel = "Abundance"),
Axis(fig[2, 1:3];
xlabel = "Generation",
ylabel = "Abundance"),
Axis(fig[3, 1:3];
xlabel = "Generation",
ylabel = "Species Richness"),
]
for species in axes(metacommunity_burnin, 3)
tl = trophic_level[species]
GLMakie.scatter!(
axs[tl],
vec(environment_burnin),
vec(metacommunity_burnin[:, :, species, end]),
)
end
abund = dropdims(mapslices(sum, metacommunity_burnin; dims = (1, 2)); dims = (1, 2))
for species in axes(abund, 1)
lines!(axs[4], abund[species, 1:end]; color = species_col[species])
end
abund[findall(abund .> 0.0), 1] .= 1.0
lines!(axs[5], vec(sum(abund[1:40, :]; dims = 1)); color = "green", label = "plant")
lines!(axs[5], vec(sum(abund[41:63, :]; dims = 1)); color = "blue", label = "herbivore")
lines!(axs[5], vec(sum(abund[64:end, :]; dims = 1)); color = "red", label = "carnivore")
axislegend()
current_figure()
save("figures/diagnostics_burnin.png", fig)
# 'heated' community
fig = Figure()
axs = [
Axis(fig[1, 1];
xlabel = "Environment value",
ylabel = "Abundance"),
Axis(fig[1, 2];
xlabel = "Environment value",
ylabel = "Abundance"),
Axis(fig[1, 3];
xlabel = "Environment value",
ylabel = "Abundance"),
Axis(fig[2, 1:3];
xlabel = "Generation",
ylabel = "Abundance"),
Axis(fig[3, 1:3];
xlabel = "Generation",
ylabel = "Species Richness"),
]
for species in axes(metacommunity, 3)
tl = trophic_level[species]
GLMakie.scatter!(
axs[tl],
vec(environment_heating[:, :, end]),
vec(metacommunity[:, :, species, end]),
)
end
abund = dropdims(mapslices(sum, metacommunity; dims = (1, 2)); dims = (1, 2))
for species in axes(abund, 1)
lines!(axs[4], abund[species, 1:end]; color = species_col[species])
end
abund[findall(abund .> 0.0), 1] .= 1.0
lines!(axs[5], vec(sum(abund[1:40, :]; dims = 1)); color = "green", label = "plant")
lines!(axs[5], vec(sum(abund[41:63, :]; dims = 1)); color = "blue", label = "herbivore")
lines!(axs[5], vec(sum(abund[64:end, :]; dims = 1)); color = "red", label = "carnivore")
axislegend()
current_figure()
save("figures/diagnostics.png", fig)