From e8b4b47ecc403b6bd5b4509e4f988d3a96bde302 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Sun, 6 Nov 2022 14:24:54 +0100 Subject: [PATCH 1/4] Update test snapshots --- R/plot.R | 4 +- .../plot-avail-forecasts.svg | 168 ++++++------ .../plot_correlation/plot-correlation.svg | 56 ++-- .../_snaps/plot_heatmap/plot-heatmap.svg | 168 ++++++------ .../plot-interval-coverage.svg | 2 +- .../plot-pairwise-comparison-pval.svg | 50 ++-- .../plot-pairwise-comparison-sib.svg | 50 ++-- .../plot-pairwise-comparison.svg | 50 ++-- .../plot-pairwise-together-sib.svg | 44 ++-- .../plot-pairwise-together.svg | 44 ++-- .../_snaps/plot_pit/plot-pit-integer.svg | 72 +++--- .../_snaps/plot_pit/plot-pit-quantile.svg | 64 ++--- .../_snaps/plot_pit/plot-pit-sample.svg | 18 +- .../many-quantiles-from-sample.svg | 192 ++------------ .../plot_predictions/many-quantiles.svg | 240 ++++-------------- .../_snaps/plot_predictions/no-median.svg | 176 ++----------- .../plot_predictions/point-forecasts.svg | 144 ----------- .../plot-quantile-coverage.svg | 2 +- .../plot_score_table/plot-score-table.svg | 56 ++-- .../_snaps/plot_wis/plot-wis-flip.svg | 48 ++-- .../_snaps/plot_wis/plot-wis-no-relative.svg | 48 ++-- tests/testthat/_snaps/plot_wis/plot-wis.svg | 48 ++-- 22 files changed, 584 insertions(+), 1160 deletions(-) diff --git a/R/plot.R b/R/plot.R index 52e2d39f8..aa7240261 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 = after_stat(width * density)), breaks = plot_quantiles, colour = "grey" ) + @@ -1066,7 +1066,7 @@ plot_pit <- function(pit, data = data.frame(x = pit), aes(x = x) ) + - geom_histogram(aes(y = stat(width*density)), + geom_histogram(aes(y = after_stat(width * density)), breaks = plot_quantiles, colour = "grey" ) diff --git a/tests/testthat/_snaps/plot_avail_forecasts/plot-avail-forecasts.svg b/tests/testthat/_snaps/plot_avail_forecasts/plot-avail-forecasts.svg index 85c01faca..e70c93f14 100644 --- a/tests/testthat/_snaps/plot_avail_forecasts/plot-avail-forecasts.svg +++ b/tests/testthat/_snaps/plot_avail_forecasts/plot-avail-forecasts.svg @@ -25,42 +25,42 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -70,54 +70,54 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/_snaps/plot_correlation/plot-correlation.svg b/tests/testthat/_snaps/plot_correlation/plot-correlation.svg index 0901fb9ef..f56619980 100644 --- a/tests/testthat/_snaps/plot_correlation/plot-correlation.svg +++ b/tests/testthat/_snaps/plot_correlation/plot-correlation.svg @@ -25,34 +25,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 0.46 1 diff --git a/tests/testthat/_snaps/plot_heatmap/plot-heatmap.svg b/tests/testthat/_snaps/plot_heatmap/plot-heatmap.svg index a0738ba57..528aefb09 100644 --- a/tests/testthat/_snaps/plot_heatmap/plot-heatmap.svg +++ b/tests/testthat/_snaps/plot_heatmap/plot-heatmap.svg @@ -25,90 +25,90 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.1 0.1 0.1 diff --git a/tests/testthat/_snaps/plot_interval_coverage/plot-interval-coverage.svg b/tests/testthat/_snaps/plot_interval_coverage/plot-interval-coverage.svg index 868c6c35c..548878c34 100644 --- a/tests/testthat/_snaps/plot_interval_coverage/plot-interval-coverage.svg +++ b/tests/testthat/_snaps/plot_interval_coverage/plot-interval-coverage.svg @@ -25,7 +25,7 @@ - + diff --git a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison-pval.svg b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison-pval.svg index b11d4c442..22e2408dc 100644 --- a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison-pval.svg +++ b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison-pval.svg @@ -25,15 +25,15 @@ - - - - - - - - - + + + + + + + + + < 0.001 < 0.001 1 @@ -52,22 +52,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + < 0.001 < 0.001 < 0.001 diff --git a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison-sib.svg b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison-sib.svg index 32742d0ff..dcaaa660d 100644 --- a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison-sib.svg +++ b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison-sib.svg @@ -25,15 +25,15 @@ - - - - - - - - - + + + + + + + + + 1.37 1.59 1 @@ -52,22 +52,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + 2.38 3.03 3.85 diff --git a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison.svg b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison.svg index d3324b4e6..1ff397cfe 100644 --- a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison.svg +++ b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-comparison.svg @@ -25,15 +25,15 @@ - - - - - - - - - + + + + + + + + + 1.37 1.59 1 @@ -52,22 +52,22 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + 2.38 3.03 3.85 diff --git a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-together-sib.svg b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-together-sib.svg index 226b6a587..57ebbf5c9 100644 --- a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-together-sib.svg +++ b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-together-sib.svg @@ -25,15 +25,15 @@ - - - + + + 1.59 1.37 1.16 - - - + + + < 0.001 < 0.001 0.298 @@ -46,24 +46,24 @@ - - - - - - + + + + + + 3.85 3.03 2.38 1.27 1.61 1.34 - - - - - - + + + + + + < 0.001 < 0.001 < 0.001 @@ -79,10 +79,10 @@ - - - - + + + + 1 1 1 diff --git a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-together.svg b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-together.svg index ca16de823..f139b8d3f 100644 --- a/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-together.svg +++ b/tests/testthat/_snaps/plot_pairwise_comparison/plot-pairwise-together.svg @@ -25,15 +25,15 @@ - - - + + + 0.63 0.86 0.73 - - - + + + < 0.001 0.298 < 0.001 @@ -46,24 +46,24 @@ - - - - - - + + + + + + 0.26 0.79 0.62 0.33 0.74 0.42 - - - - - - + + + + + + < 0.001 < 0.001 < 0.001 @@ -79,10 +79,10 @@ - - - - + + + + 1 1 1 diff --git a/tests/testthat/_snaps/plot_pit/plot-pit-integer.svg b/tests/testthat/_snaps/plot_pit/plot-pit-integer.svg index 1b6704758..5f26fe7e1 100644 --- a/tests/testthat/_snaps/plot_pit/plot-pit-integer.svg +++ b/tests/testthat/_snaps/plot_pit/plot-pit-integer.svg @@ -25,15 +25,15 @@ - - - - - - - - - + + + + + + + + + @@ -43,15 +43,15 @@ - - - - - - - - - + + + + + + + + + @@ -61,15 +61,15 @@ - - - - - - - - - + + + + + + + + + @@ -79,15 +79,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/tests/testthat/_snaps/plot_pit/plot-pit-quantile.svg b/tests/testthat/_snaps/plot_pit/plot-pit-quantile.svg index ab88b2889..ff1eb2aff 100644 --- a/tests/testthat/_snaps/plot_pit/plot-pit-quantile.svg +++ b/tests/testthat/_snaps/plot_pit/plot-pit-quantile.svg @@ -25,14 +25,14 @@ - - - - - - - - + + + + + + + + @@ -42,14 +42,14 @@ - - - - - - - - + + + + + + + + @@ -59,14 +59,14 @@ - - - - - - - - + + + + + + + + @@ -76,14 +76,14 @@ - - - - - - - - + + + + + + + + diff --git a/tests/testthat/_snaps/plot_pit/plot-pit-sample.svg b/tests/testthat/_snaps/plot_pit/plot-pit-sample.svg index 8c5ff2673..68e6797af 100644 --- a/tests/testthat/_snaps/plot_pit/plot-pit-sample.svg +++ b/tests/testthat/_snaps/plot_pit/plot-pit-sample.svg @@ -25,15 +25,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/tests/testthat/_snaps/plot_predictions/many-quantiles-from-sample.svg b/tests/testthat/_snaps/plot_predictions/many-quantiles-from-sample.svg index f01852049..604ce007a 100644 --- a/tests/testthat/_snaps/plot_predictions/many-quantiles-from-sample.svg +++ b/tests/testthat/_snaps/plot_predictions/many-quantiles-from-sample.svg @@ -25,9 +25,9 @@ - - - + + + @@ -50,9 +50,9 @@ - - - + + + @@ -75,9 +75,9 @@ - - - + + + @@ -100,9 +100,9 @@ - - - + + + @@ -125,9 +125,9 @@ - - - + + + @@ -150,9 +150,9 @@ - - - + + + @@ -175,9 +175,9 @@ - - - + + + @@ -200,9 +200,9 @@ - - - + + + @@ -234,27 +234,9 @@ - - - - - - - IT - - - - - - - - - Cases - - @@ -263,27 +245,9 @@ - - - - - - - IT - - - - - - - - - Deaths - - @@ -301,27 +265,9 @@ - - - - - - - FR - - - - - - - - - Deaths - - @@ -330,27 +276,9 @@ - - - - - - - GB - - - - - - - - - Cases - - @@ -359,27 +287,9 @@ - - - - - - - GB - - - - - - - - - Deaths - - @@ -388,27 +298,9 @@ - - - - - - - DE - - - - - - - - - Cases - - @@ -417,27 +309,9 @@ - - - - - - - DE - - - - - - - - - Deaths - - @@ -446,27 +320,9 @@ - - - - - - - FR - - - - - - - - - Cases - - diff --git a/tests/testthat/_snaps/plot_predictions/many-quantiles.svg b/tests/testthat/_snaps/plot_predictions/many-quantiles.svg index d1ddddb2b..6c805a6f0 100644 --- a/tests/testthat/_snaps/plot_predictions/many-quantiles.svg +++ b/tests/testthat/_snaps/plot_predictions/many-quantiles.svg @@ -25,12 +25,12 @@ - - - - - - + + + + + + @@ -53,12 +53,12 @@ - - - - - - + + + + + + @@ -81,12 +81,12 @@ - - - - - - + + + + + + @@ -109,12 +109,12 @@ - - - - - - + + + + + + @@ -137,12 +137,12 @@ - - - - - - + + + + + + @@ -165,12 +165,12 @@ - - - - - - + + + + + + @@ -193,12 +193,12 @@ - - - - - - + + + + + + @@ -221,12 +221,12 @@ - - - - - - + + + + + + @@ -258,27 +258,9 @@ - - - - - - - IT - - - - - - - - - Cases - - @@ -287,27 +269,9 @@ - - - - - - - IT - - - - - - - - - Deaths - - @@ -325,27 +289,9 @@ - - - - - - - FR - - - - - - - - - Deaths - - @@ -354,27 +300,9 @@ - - - - - - - GB - - - - - - - - - Cases - - @@ -383,27 +311,9 @@ - - - - - - - GB - - - - - - - - - Deaths - - @@ -412,27 +322,9 @@ - - - - - - - DE - - - - - - - - - Cases - - @@ -441,27 +333,9 @@ - - - - - - - DE - - - - - - - - - Deaths - - @@ -470,27 +344,9 @@ - - - - - - - FR - - - - - - - - - Cases - - diff --git a/tests/testthat/_snaps/plot_predictions/no-median.svg b/tests/testthat/_snaps/plot_predictions/no-median.svg index 87b9929f7..bac56aa5f 100644 --- a/tests/testthat/_snaps/plot_predictions/no-median.svg +++ b/tests/testthat/_snaps/plot_predictions/no-median.svg @@ -25,8 +25,8 @@ - - + + @@ -40,8 +40,8 @@ - - + + @@ -55,8 +55,8 @@ - - + + @@ -70,8 +70,8 @@ - - + + @@ -85,8 +85,8 @@ - - + + @@ -100,8 +100,8 @@ - - + + @@ -115,8 +115,8 @@ - - + + @@ -130,8 +130,8 @@ - - + + @@ -154,27 +154,9 @@ - - - - - - - United Kingdom - - - - - - - - - Cases - - @@ -183,27 +165,9 @@ - - - - - - - United Kingdom - - - - - - - - - Deaths - - @@ -221,27 +185,9 @@ - - - - - - - Germany - - - - - - - - - Deaths - - @@ -250,27 +196,9 @@ - - - - - - - Italy - - - - - - - - - Cases - - @@ -279,27 +207,9 @@ - - - - - - - Italy - - - - - - - - - Deaths - - @@ -308,27 +218,9 @@ - - - - - - - France - - - - - - - - - Cases - - @@ -337,27 +229,9 @@ - - - - - - - France - - - - - - - - - Deaths - - @@ -366,27 +240,9 @@ - - - - - - - Germany - - - - - - - - - Cases - - diff --git a/tests/testthat/_snaps/plot_predictions/point-forecasts.svg b/tests/testthat/_snaps/plot_predictions/point-forecasts.svg index 04f36e6cd..1d7048d2f 100644 --- a/tests/testthat/_snaps/plot_predictions/point-forecasts.svg +++ b/tests/testthat/_snaps/plot_predictions/point-forecasts.svg @@ -210,27 +210,9 @@ - - - - - - - IT - - - - - - - - - Cases - - @@ -239,27 +221,9 @@ - - - - - - - IT - - - - - - - - - Deaths - - @@ -277,27 +241,9 @@ - - - - - - - FR - - - - - - - - - Deaths - - @@ -306,27 +252,9 @@ - - - - - - - GB - - - - - - - - - Cases - - @@ -335,27 +263,9 @@ - - - - - - - GB - - - - - - - - - Deaths - - @@ -364,27 +274,9 @@ - - - - - - - DE - - - - - - - - - Cases - - @@ -393,27 +285,9 @@ - - - - - - - DE - - - - - - - - - Deaths - - @@ -422,27 +296,9 @@ - - - - - - - FR - - - - - - - - - Cases - - diff --git a/tests/testthat/_snaps/plot_quantile_coverage/plot-quantile-coverage.svg b/tests/testthat/_snaps/plot_quantile_coverage/plot-quantile-coverage.svg index 6450da745..bf686eedb 100644 --- a/tests/testthat/_snaps/plot_quantile_coverage/plot-quantile-coverage.svg +++ b/tests/testthat/_snaps/plot_quantile_coverage/plot-quantile-coverage.svg @@ -25,7 +25,7 @@ - + diff --git a/tests/testthat/_snaps/plot_score_table/plot-score-table.svg b/tests/testthat/_snaps/plot_score_table/plot-score-table.svg index 5bf977053..95f9fe247 100644 --- a/tests/testthat/_snaps/plot_score_table/plot-score-table.svg +++ b/tests/testthat/_snaps/plot_score_table/plot-score-table.svg @@ -25,34 +25,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10000 9000 50 diff --git a/tests/testthat/_snaps/plot_wis/plot-wis-flip.svg b/tests/testthat/_snaps/plot_wis/plot-wis-flip.svg index 8e485e07a..758a3c147 100644 --- a/tests/testthat/_snaps/plot_wis/plot-wis-flip.svg +++ b/tests/testthat/_snaps/plot_wis/plot-wis-flip.svg @@ -25,15 +25,15 @@ - - - - - - - - - + + + + + + + + + @@ -43,18 +43,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + @@ -109,9 +109,9 @@ model WIS contributions WIS component - - - + + + overprediction underprediction dispersion diff --git a/tests/testthat/_snaps/plot_wis/plot-wis-no-relative.svg b/tests/testthat/_snaps/plot_wis/plot-wis-no-relative.svg index 93a46adbc..987072ca4 100644 --- a/tests/testthat/_snaps/plot_wis/plot-wis-no-relative.svg +++ b/tests/testthat/_snaps/plot_wis/plot-wis-no-relative.svg @@ -25,15 +25,15 @@ - - - - - - - - - + + + + + + + + + @@ -43,18 +43,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + @@ -103,9 +103,9 @@ WIS contributions model WIS component - - - + + + overprediction underprediction dispersion diff --git a/tests/testthat/_snaps/plot_wis/plot-wis.svg b/tests/testthat/_snaps/plot_wis/plot-wis.svg index 13dcf0634..5328b4779 100644 --- a/tests/testthat/_snaps/plot_wis/plot-wis.svg +++ b/tests/testthat/_snaps/plot_wis/plot-wis.svg @@ -25,15 +25,15 @@ - - - - - - - - - + + + + + + + + + @@ -43,18 +43,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + @@ -111,9 +111,9 @@ WIS contributions model WIS component - - - + + + overprediction underprediction dispersion From d4ce20e9855fd021db410e9c12833f6e55669012 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Sun, 6 Nov 2022 14:41:42 +0100 Subject: [PATCH 2/4] switch from size to linewidth in geom_line --- R/plot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/plot.R b/R/plot.R index aa7240261..e417a37cb 100644 --- a/R/plot.R +++ b/R/plot.R @@ -260,7 +260,7 @@ plot_ranges <- function(scores, geom_point(size = 2) + geom_line(aes(group = range), colour = "black", - size = 0.01 + linewidth = 0.01 ) + scale_color_continuous(low = "steelblue", high = "salmon") + theme_scoringutils() + From 84a305bc34876abbc7dea29b0d9fc4ef92edf28e Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Thu, 17 Nov 2022 10:45:57 -0600 Subject: [PATCH 3/4] update description to require newest ggplot version --- DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cdaf1340e..c5fe0d8f6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -47,8 +47,8 @@ Encoding: UTF-8 LazyData: true Imports: data.table, - ggdist (>= 3.1.0), - ggplot2, + ggdist (>= 3.2.0), + ggplot2 (>= 3.4.0), methods, rlang, scoringRules, @@ -64,7 +64,7 @@ Config/Needs/website: r-lib/pkgdown, amirmasoudabdol/preferably Config/testthat/edition: 3 -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 URL: https://epiforecasts.io/scoringutils/, https://github.com/epiforecasts/scoringutils BugReports: https://github.com/epiforecasts/scoringutils/issues VignetteBuilder: knitr From b7f896a9aa6c5023e4b87ed50298e710e958f651 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Thu, 17 Nov 2022 11:22:33 -0600 Subject: [PATCH 4/4] add after_stat to package imports --- NAMESPACE | 1 + R/plot.R | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index da92c314b..0604e2725 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -63,6 +63,7 @@ importFrom(ggdist,geom_lineribbon) importFrom(ggplot2,.data) importFrom(ggplot2,`%+replace%`) importFrom(ggplot2,aes) +importFrom(ggplot2,after_stat) importFrom(ggplot2,coord_cartesian) importFrom(ggplot2,coord_flip) importFrom(ggplot2,element_blank) diff --git a/R/plot.R b/R/plot.R index e417a37cb..3bbdcd57a 100644 --- a/R/plot.R +++ b/R/plot.R @@ -993,7 +993,7 @@ plot_pairwise_comparison <- function(comparison_result, #' # sample-based pit #' pit <- pit(example_integer, by = c("model")) #' plot_pit(pit) -#' @importFrom ggplot2 ggplot aes xlab ylab geom_histogram stat theme_light +#' @importFrom ggplot2 ggplot aes xlab ylab geom_histogram stat theme_light after_stat #' @export plot_pit <- function(pit,