From f0ab4222f1cd1fa71825dd1864c92c2693ee0346 Mon Sep 17 00:00:00 2001 From: Elio Campitelli Date: Wed, 4 Sep 2024 15:36:28 +1000 Subject: [PATCH] Computes breaks with the krigged data --- R/stat_contour2.r | 14 +++++++------- R/stat_contour_fill.R | 14 ++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/R/stat_contour2.r b/R/stat_contour2.r index f0b60f4e..b7029e8a 100644 --- a/R/stat_contour2.r +++ b/R/stat_contour2.r @@ -111,13 +111,6 @@ StatContour2 <- ggplot2::ggproto("StatContour2", ggplot2::Stat, ywrap = NULL, na.fill = FALSE, global.breaks = TRUE, proj = NULL, proj.latlon = TRUE, kriging = FALSE, clip = NULL) { - if (isFALSE(global.breaks)) { - breaks <- setup_breaks(data, - breaks = breaks, - bins = bins, - binwidth = binwidth) - } - data.table::setDT(data) data <- data[!(is.na(y) | is.na(x)), ] @@ -166,6 +159,13 @@ StatContour2 <- ggplot2::ggproto("StatContour2", ggplot2::Stat, data <- suppressWarnings(WrapCircular(data, "y", ywrap)) } + if (isFALSE(global.breaks)) { + breaks <- setup_breaks(data, + breaks = breaks, + bins = bins, + binwidth = binwidth) + } + data.table::setDF(data) dec <- getOption("OutDec") options(OutDec = ".") diff --git a/R/stat_contour_fill.R b/R/stat_contour_fill.R index 01b93900..38a784cb 100644 --- a/R/stat_contour_fill.R +++ b/R/stat_contour_fill.R @@ -91,14 +91,6 @@ StatContourFill <- ggplot2::ggproto("StatContourFill", ggplot2::Stat, proj = NULL, proj.latlon = TRUE, kriging = FALSE, clip = NULL) { data.table::setDT(data) - - if (isFALSE(global.breaks)) { - breaks <- setup_breaks(data, - breaks = breaks, - bins = bins, - binwidth = binwidth) - } - data <- data[!(is.na(y) | is.na(x)), ] if (!isFALSE(na.fill)) { @@ -141,6 +133,12 @@ StatContourFill <- ggplot2::ggproto("StatContourFill", ggplot2::Stat, data <- suppressWarnings(WrapCircular(data, "y", ywrap)) } + if (isFALSE(global.breaks)) { + breaks <- setup_breaks(data, + breaks = breaks, + bins = bins, + binwidth = binwidth) + } # Make contours dec <- getOption("OutDec")