From 7616ddc1fc563f2bfb0162fdfff450d7ea62ec82 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Thu, 18 Aug 2022 22:25:13 +0200 Subject: [PATCH 1/3] fix pit histogram plot in #240 --- R/plot.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/plot.R b/R/plot.R index 392d0119d..bdc6f63fd 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1053,7 +1053,7 @@ plot_pit <- function(pit, data = pit, aes(x = pit_value) ) + - geom_histogram(aes(y = stat(count) / sum(count)), + geom_histogram(aes(y = stat(width*density)), breaks = plot_quantiles, colour = "grey" ) + @@ -1065,7 +1065,7 @@ plot_pit <- function(pit, data = data.frame(x = pit), aes(x = x) ) + - geom_histogram(aes(y = stat(count) / sum(count)), + geom_histogram(aes(y = stat(width*density)), breaks = plot_quantiles, colour = "grey" ) From a3780e6abf0e16acf2abeb85eb6e4fc7d4a7a056 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Thu, 18 Aug 2022 22:58:11 +0200 Subject: [PATCH 2/3] add necessary import to namespace --- NAMESPACE | 1 + R/plot.R | 1 + .../_snaps/plot_pit/plot-pit-integer.svg | 82 ++++++++++--------- 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 8d4631879..da92c314b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -104,6 +104,7 @@ importFrom(scoringRules,dss_sample) importFrom(scoringRules,logs_sample) importFrom(stats,as.formula) importFrom(stats,cor) +importFrom(stats,density) importFrom(stats,mad) importFrom(stats,median) importFrom(stats,na.omit) diff --git a/R/plot.R b/R/plot.R index bdc6f63fd..52e2d39f8 100644 --- a/R/plot.R +++ b/R/plot.R @@ -977,6 +977,7 @@ plot_pairwise_comparison <- function(comparison_result, #' `num_bins`. #' @importFrom stats as.formula #' @importFrom ggplot2 geom_col +#' @importFrom stats density #' @return vector with the scoring values #' @examples #' # PIT histogram in vector based format diff --git a/tests/testthat/_snaps/plot_pit/plot-pit-integer.svg b/tests/testthat/_snaps/plot_pit/plot-pit-integer.svg index e7385a3a2..1b6704758 100644 --- a/tests/testthat/_snaps/plot_pit/plot-pit-integer.svg +++ b/tests/testthat/_snaps/plot_pit/plot-pit-integer.svg @@ -43,15 +43,15 @@ - - - - - - - - - + + + + + + + + + @@ -61,15 +61,15 @@ - - - - - - - - - + + + + + + + + + @@ -79,15 +79,15 @@ - - - - - - - - - + + + + + + + + + @@ -150,22 +150,26 @@ 1.00 0.00 -0.02 -0.04 -0.06 +0.05 +0.10 +0.15 +0.20 - - - + + + + 0.00 -0.02 -0.04 -0.06 +0.05 +0.10 +0.15 +0.20 - - - + + + + PIT Frequency plot_pit_integer From dfd52e405c657087d88112bb24b97616a1bc561a Mon Sep 17 00:00:00 2001 From: Nikos Bosse <37978797+nikosbosse@users.noreply.github.com> Date: Sun, 9 Oct 2022 17:31:15 +0200 Subject: [PATCH 3/3] Code formatting --- R/plot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/plot.R b/R/plot.R index 52e2d39f8..8834384d9 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1054,7 +1054,7 @@ plot_pit <- function(pit, data = pit, aes(x = pit_value) ) + - geom_histogram(aes(y = stat(width*density)), + geom_histogram(aes(y = stat(width * density)), breaks = plot_quantiles, colour = "grey" ) +