From 1d9779a43ee1d49cb24ecdd54d9a15df11015b04 Mon Sep 17 00:00:00 2001
From: Daniel Vedder <daniel.vedder@idiv.de>
Date: Fri, 6 Oct 2023 16:07:24 +0200
Subject: [PATCH] Prettified population trend plot

---
 src/analysis/makieplots.jl | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/analysis/makieplots.jl b/src/analysis/makieplots.jl
index 3422917..691c7f9 100644
--- a/src/analysis/makieplots.jl
+++ b/src/analysis/makieplots.jl
@@ -39,12 +39,15 @@ Returns a Makie figure object.
 """
 function populationtrends(model::AgentBasedModel)
     pops = model.datatables["populations"]
+    dates = @param(core.startdate):@param(core.enddate)
     f = Figure()
-    ax = Axis(f[1,1])
+    ax = Axis(f[1,1], xlabel="Date", ylabel="Population size",
+              xtickformat = timeseries -> [Dates.format(dates[Int(d+1)], "dd/mm/yyyy")
+                                           for d in timeseries])
     for s in unique(pops.Species)
         points = @select!(@subset(pops, :Species .== s), :Abundance)
-        lines!(f[1,1], Vector{Float32}(points.Abundance))
+        lines!(f[1,1], Vector{Float32}(points.Abundance), linewidth=3, label=s)
     end
-    #TODO prettify, add legend & labels
+    axislegend("Species"; position=:lt)
     f
 end
-- 
GitLab