Skip to content

Commit 0ea25a9

Browse files
authored
Merge pull request #365 from sizespectrum/copilot/plotbiomassobservedvsmodel-fix-default-ratio
Unify `plotBiomassObservedVsModel` default `ratio` behavior to `FALSE`
2 parents 163e6a0 + 9be04d2 commit 0ea25a9

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ the mathematical details.
334334

335335
## Breaking changes
336336

337+
- The default `ratio` argument in `plotBiomassObservedVsModel()` and
338+
`plotlyBiomassObservedVsModel()` is now consistently `FALSE` for all object
339+
types. Calls that relied on the previous default ratio plot should now set
340+
`ratio = TRUE`.
341+
337342
- The first argument of `plotBiomass()`, `plotYield()`, `plotYieldGear()` and
338343
their `MizerSim` methods and `plotly*` wrappers has been renamed from `sim`
339344
to `object` for consistency with other plot generics. Calls using

R/plotBiomassObservedVsModel.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#' `biomass_observed` column in the species parameter data frame, this function
66
#' plots the biomass of each species in the model against the observed
77
#' biomasses. When called with a MizerSim object, the plot will use the model
8-
#' biomasses predicted for the final time step in the simulation. For the
9-
#' MizerSim and plotly methods, `ratio` defaults to `FALSE`.
8+
#' biomasses predicted for the final time step in the simulation. `ratio`
9+
#' defaults to `FALSE`.
1010
#'
1111
#' Before you can use this function you will need to have added a
1212
#' `biomass_observed` column to your model which gives the observed biomass in
@@ -30,7 +30,7 @@
3030
#' with the species indices, or a logical vector indicating for each species
3131
#' whether it is to be included (TRUE) or not.
3232
#' @param ratio Whether to plot model biomass vs. observed biomass (FALSE) or
33-
#' the ratio of model : observed biomass (TRUE). Default is TRUE.
33+
#' the ratio of model : observed biomass (TRUE). Default is FALSE.
3434
#' @param log_scale Whether to plot on the log10 scale (TRUE) or not (FALSE).
3535
#' For the non-ratio plot this applies for both axes, for the ratio plot only
3636
#' the x-axis is on the log10 scale. Default is TRUE.
@@ -65,14 +65,14 @@
6565
#' plotBiomassObservedVsModel(params, show_unobserved = TRUE, ratio = FALSE)
6666
#'
6767
#' # Show the ratio instead
68-
#' plotBiomassObservedVsModel(params)
69-
plotBiomassObservedVsModel <- function(object, species = NULL, ratio = TRUE,
68+
#' plotBiomassObservedVsModel(params, ratio = TRUE)
69+
plotBiomassObservedVsModel <- function(object, species = NULL, ratio = FALSE,
7070
log_scale = TRUE, return_data = FALSE,
7171
labels = TRUE, show_unobserved = FALSE, ...) {
7272
UseMethod("plotBiomassObservedVsModel")
7373
}
7474
#' @export
75-
plotBiomassObservedVsModel.MizerParams <- function(object, species = NULL, ratio = TRUE,
75+
plotBiomassObservedVsModel.MizerParams <- function(object, species = NULL, ratio = FALSE,
7676
log_scale = TRUE, return_data = FALSE,
7777
labels = TRUE, show_unobserved = FALSE, ...) {
7878
# preliminary checks

tests/testthat/test-plotBiomassObservedVsModel.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ expect_equal(nrow(dummy), length(sp_select))
4141
expect_equal(dummy$observed,
4242
species_params(params)$biomass_observed[sp_select])
4343

44-
# Finally, look at plot of ratio
44+
# Finally, look at default plot (model biomass vs observed biomass)
4545
dummy <- plotBiomassObservedVsModel(params, return_data = TRUE)
4646
p <- plotBiomassObservedVsModel(params)
4747
expect_true(is_ggplot(p))
4848
expect_identical(p$labels$x, "observed biomass [g]")
49-
expect_identical(p$labels$y, "model biomass / observed biomass")
49+
expect_identical(p$labels$y, "model biomass [g]")
5050
expect_identical(p$data, dummy)
5151

52-
# Look at plot as model biomass vs. observed biomass
53-
dummy <- plotBiomassObservedVsModel(params, ratio = F, return_data = TRUE)
54-
p <- plotBiomassObservedVsModel(params, ratio = F)
55-
expect_identical(p$labels$y, "model biomass [g]")
52+
# Look at plot of ratio
53+
dummy <- plotBiomassObservedVsModel(params, ratio = TRUE, return_data = TRUE)
54+
p <- plotBiomassObservedVsModel(params, ratio = TRUE)
55+
expect_identical(p$labels$y, "model biomass / observed biomass")
5656
expect_identical(p$data, dummy)
5757

5858
vdiffr::expect_doppelganger("plotBiomassObservedVsModel", p)

0 commit comments

Comments
 (0)