From 42deebdf13d9d79d2d34e91690eadada0c9ce30d Mon Sep 17 00:00:00 2001 From: Marco Colombo Date: Thu, 19 Dec 2024 16:26:07 +0100 Subject: [PATCH] Plot the natural curve for extrapolation also in the negative quadrant. --- NEWS.Rmd | 4 ++++ NEWS.md | 4 ++++ R/calc_Huntley2006.R | 9 +++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/NEWS.Rmd b/NEWS.Rmd index b42e0b1a9..c49b516b1 100644 --- a/NEWS.Rmd +++ b/NEWS.Rmd @@ -183,6 +183,10 @@ speed boost. The default setting can be overridden via the `rprime` argument use to find a good starting point failed: in such cases, we try again using the simulated fit (#549, fixed in #500; thanks to @SalOehl for reporting and providing data to reproduce the error). +* The natural/simulated curve was not plotted in the negative quadrant for +`mode = "extrapolation"`, which made it harder to see where it extrapolated +to (#551, fixed in #552; thanks to @SalOehl for reporting). + ### `calc_IEU()` * The code of this function has been consolidated to avoid duplication and diff --git a/NEWS.md b/NEWS.md index 51e9f6829..d8c4f7890 100644 --- a/NEWS.md +++ b/NEWS.md @@ -214,6 +214,10 @@ model we use to find a good starting point failed: in such cases, we try again using the simulated fit (#549, fixed in \#500; thanks to @SalOehl for reporting and providing data to reproduce the error). +- The natural/simulated curve was not plotted in the negative quadrant + for `mode = "extrapolation"`, which made it harder to see where it + extrapolated to (#551, fixed in \#552; thanks to @SalOehl for + reporting). ### `calc_IEU()` diff --git a/R/calc_Huntley2006.R b/R/calc_Huntley2006.R index abc5d78d4..6297d4cb7 100644 --- a/R/calc_Huntley2006.R +++ b/R/calc_Huntley2006.R @@ -866,9 +866,14 @@ calc_Huntley2006 <- function( col = adjustcolor("grey", alpha.f = 0.5), border = NA) ## add simulated curve ------- + xNew <- seq(if (mode_is_extrapolation) par()$usr[1] else 0, + par()$usr[2], length.out = 200) + yNew <- predict(GC.simulated@data$Fit, list(x = xNew)) + if (normalise) + yNew <- yNew / A points( - x = natdosetimeGray, - y = LxTx_simulated$LxTx, + x = xNew, + y = yNew, type = "l", lty = 3)