From 12109332612f8742406f4fdeb252dabd5b2f5796 Mon Sep 17 00:00:00 2001 From: Andreas Gattringer <andreas.gattringer@univie.ac.at> Date: Mon, 5 Jun 2023 13:16:12 +0200 Subject: [PATCH] plot_cats_run(): added legend title and specified plot function Signed-off-by: Andreas Gattringer <andreas.gattringer@univie.ac.at> --- R/cats_analysis.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/R/cats_analysis.R b/R/cats_analysis.R index 8c7c5e2..def8c0f 100644 --- a/R/cats_analysis.R +++ b/R/cats_analysis.R @@ -118,7 +118,7 @@ plot_cats_run <- function(results, catsconfig, run.name = NULL, replicate = 0) { if (is.na(cc)) { terra::plot(r, main = title) } else { - terra::plot(r, range = c(0, cc), main = title) + terra::plot(r, range = c(0, cc), main = title, plg=list(title="Number of adults")) } last <- r } @@ -137,7 +137,6 @@ plot_cats_run <- function(results, catsconfig, run.name = NULL, replicate = 0) { x <- last - first no_pop <- (last == 0 & first == 0)*1 - no_pop <- terra::mask(x * 0, mask=no_pop, maskvalues=0) * 0 losses <-(x == -1)*1 @@ -173,7 +172,7 @@ plot_cats_run <- function(results, catsconfig, run.name = NULL, replicate = 0) { } - plot(populated ~ years, type="l", ylim=c(0, max_cells), main="Range size (cells)", xlab="Year", ylab="Cells") + base::plot(populated ~ years, type="l", ylim=c(0, max_cells), main="Range size (cells)", xlab="Year", ylab="Cells") graphics::lines(populated_fit ~ years, col="blue") graphics::lines(populated_unfit ~ years, col="red") graphics::legend(x = min(years), y=max(populated/2), legend=c("Populated cells (all)", "Populated cells (fit)", "Populated cells (unfit)"), col=c("black", "blue", "red"), lty=1) -- GitLab