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 392d0119d..8834384d9 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
@@ -1053,7 +1054,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 +1066,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"
)
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