Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
bde4115
Update WORDLIST
VEZY Apr 30, 2025
abe41c4
Update test-scatter-plots.R
VEZY Apr 30, 2025
34dad91
Use || instead of |
VEZY Apr 30, 2025
558f0c6
Update generic_plotting.R
VEZY Apr 30, 2025
8dce71a
Fix linter issues
VEZY Apr 30, 2025
b27dc85
Update test-scatter-plots.R
VEZY Apr 30, 2025
16cd56a
fix typo
VEZY Apr 30, 2025
b7b190d
| -> || and & -> &&
VEZY Apr 30, 2025
661f527
Update specific_plotting_scatter.R
VEZY Apr 30, 2025
206310c
Update specific_plotting_scatter.R
VEZY Apr 30, 2025
43bdaff
Update test-scatter-plots.R
VEZY Apr 30, 2025
adc91c0
Removed WIP badge
sbuis Jun 4, 2025
e6893db
add plot successive
cyrillemidingoyi Jun 4, 2025
495d20b
Merge e6893dbaee1f1d646dcccdd7c5ec28d4be0fe171 into 00294e49685715725…
VEZY Jun 4, 2025
400217c
Style code (GHA)
cyrillemidingoyi Jun 4, 2025
236cd71
add plot successive
cyrillemidingoyi Jun 4, 2025
80051b9
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
cyrillemidingoyi Jun 4, 2025
ca57bc7
Merge 80051b9ceec41a047ed10c01e16a388b2aea3aca into 00294e49685715725…
VEZY Jun 4, 2025
fa66ed0
Style code (GHA)
cyrillemidingoyi Jun 4, 2025
2961801
add plot successive)
cyrillemidingoyi Jun 4, 2025
209af9b
add plot successive
cyrillemidingoyi Jun 4, 2025
872cd1d
add plot successive
cyrillemidingoyi Jun 4, 2025
107566d
add plot successive
cyrillemidingoyi Jun 4, 2025
b97677c
add plot successive
cyrillemidingoyi Jun 5, 2025
ba36740
Merge b97677c3ed248d5107ea8fb691e44eb16a6114a7 into 00294e49685715725…
VEZY Jun 5, 2025
56cf6b8
Style code (GHA)
cyrillemidingoyi Jun 5, 2025
e4a4cea
Update WORDLIST
VEZY Apr 30, 2025
1bf0d9e
Use || instead of |
VEZY Apr 30, 2025
da10999
Fix linter issues
VEZY Apr 30, 2025
8813070
fix typo
VEZY Apr 30, 2025
73d92f3
| -> || and & -> &&
VEZY Apr 30, 2025
13144df
Update specific_plotting_scatter.R
VEZY Apr 30, 2025
3f7fed0
Update specific_plotting_scatter.R
VEZY Apr 30, 2025
093ca85
Update test-scatter-plots.R
VEZY Apr 30, 2025
7b3f870
Removed WIP badge
sbuis Jun 4, 2025
38f939b
Add plot_scat_persit (per situation)
VEZY Jun 5, 2025
10a952e
add plot successive
cyrillemidingoyi Jun 5, 2025
4a5dfbb
Style code (GHA)
cyrillemidingoyi Jun 5, 2025
94f7a6f
Using standard version of pak
VEZY Jun 5, 2025
a534cee
And use standard version of pak for vdiffr too
VEZY Jun 5, 2025
c96558a
Up documentation
VEZY Jul 23, 2025
c69ad6d
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
sbuis Jul 23, 2025
3a92f39
Back to beg. june version following pb with rebase
sbuis Jul 23, 2025
87f69ab
Using standard version of pak (not rc)
VEZY Jul 23, 2025
737ce05
Up doc
VEZY Jul 23, 2025
14370f6
Merge pull request #1 from SticsRPacks/code-refactoring
cyrillemidingoyi Jul 23, 2025
65503d6
update scatter plot fig 1
cyrillemidingoyi Jul 23, 2025
8d43f2b
update scatter plot fig 1
cyrillemidingoyi Jul 23, 2025
8ce24b2
Merge pull request #74 from cyrillemidingoyi/code-refactoring
cyrillemidingoyi Jul 23, 2025
9e82a2f
feat: extend scatter plot with non_mixture_no_versions_per_situations…
cyrillemidingoyi Sep 3, 2025
b458291
Fix: use of get_usm_list (#79)
sbuis Sep 3, 2025
8a6d67d
Merge branch 'code-refactoring' into code-refactoring
sbuis Sep 3, 2025
13fb171
feat: extend scatter plot with non_mixture_no_versions_per_situations…
cyrillemidingoyi Sep 3, 2025
179c4d7
Merge pull request #78 from cyrillemidingoyi/code-refactoring
cyrillemidingoyi Sep 3, 2025
3601eba
Merge pull request #2 from SticsRPacks/code-refactoring
cyrillemidingoyi Oct 16, 2025
cc9e22a
Merge pull request #87 from cyrillemidingoyi/code-refactoring
cyrillemidingoyi Oct 16, 2025
25122ff
Use Figure number from the reference csv for naming the figure instea…
VEZY Oct 16, 2025
9028745
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
VEZY Oct 16, 2025
887d990
Make Scatter Fig 8 and 9
VEZY Oct 16, 2025
47cb080
Merge pull request #3 from SticsRPacks/code-refactoring
cyrillemidingoyi Oct 16, 2025
47e3cb4
Delete figures generated by previous tests before running the new tests
VEZY Oct 16, 2025
1b17001
Add version back to the simulation data when scatter or select_dyn ==…
VEZY Oct 16, 2025
6de0557
Merge pull request #4 from SticsRPacks/code-refactoring
cyrillemidingoyi Oct 16, 2025
d7bcccc
Add mixture_versions_per_situations -> plots 17 and 18
VEZY Oct 16, 2025
991c5c3
Update specific_plotting_scatter.R
VEZY Oct 16, 2025
c43086d
Update tests_scatter_plots.csv
VEZY Oct 16, 2025
2222d85
mixture_versions_situations and mixture_versions_per_situations share…
VEZY Oct 16, 2025
be6bde7
Merge pull request #5 from SticsRPacks/code-refactoring
cyrillemidingoyi Oct 17, 2025
3405bd5
update csv file
cyrillemidingoyi Oct 17, 2025
e642740
WIP: local changes before pulling
cyrillemidingoyi Oct 17, 2025
a692b65
update generic plotting
cyrillemidingoyi Oct 17, 2025
c41c8d2
Merge branch 'code-refactoring' of https://github.com/cyrillemidingoy…
cyrillemidingoyi Oct 17, 2025
9f43b80
update plotting scatter
cyrillemidingoyi Oct 17, 2025
0890578
update scatter plot with non mixture version (#93)
cyrillemidingoyi Oct 17, 2025
61ea4e1
Fix #91
VEZY Oct 17, 2025
880d46d
update test_scatter_csv file
cyrillemidingoyi Oct 17, 2025
56c3811
Merge branch 'code-refactoring' into code-refactoring
cyrillemidingoyi Oct 17, 2025
c7b7e99
update test_scatter_csv file (#96)
cyrillemidingoyi Oct 17, 2025
ac32d98
Fix warning "Unknown or uninitialised column: Plant
sbuis Dec 10, 2025
4fbe999
Rename variable to var in data dataframe for plotly compatibility
vrahier Dec 11, 2025
b108939
Remove duplicate code in specific_plotting_scatter.R
vrahier Dec 11, 2025
5638c8b
Rename variable to var in plot.statistics function
vrahier Dec 16, 2025
e11dd9e
Remove unused aesthetics code
vrahier Jan 12, 2026
177e6e0
Merge branch 'main' into code-refactoring
vrahier Jan 12, 2026
f7fa2b4
Remove fixed ggplot2 version from test-coverage.yaml file
vrahier Jan 12, 2026
d3cc6d7
Merge f7fa2b4b49d25b1b6edcc1d717b7027f06dd1909 into 8090d060d63302988…
VEZY Jan 12, 2026
c4850af
Style code (GHA)
vrahier Jan 12, 2026
418b4dd
Revert zzz.R
vrahier Jan 12, 2026
5d030ee
Merge 418b4dde84697cb14a84bae777961ff804422038 into 8090d060d63302988…
VEZY Jan 12, 2026
79fcffe
Style code (GHA)
vrahier Jan 12, 2026
71195c1
Remove tests on ggplot$labels as they are not as consistant in ggplot…
VEZY Jan 12, 2026
85ed588
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
VEZY Jan 12, 2026
db0fdc8
Fix check-standard.yaml file format
vrahier Jan 12, 2026
00aa6b5
Update test-dynamic-plots.R
VEZY Jan 12, 2026
ece0931
Roll-back tests on labels for scatter plots
VEZY Jan 12, 2026
ef07d9b
Use labels instead of text in aes for ggplotly compatibility
VEZY Jan 12, 2026
e0561ce
Avoid saving plots twice (bad previous merge?)
VEZY Jan 12, 2026
c1bf245
Merge branch 'fix-warning-in-ggplot-for-text-aes-for-ggplotly' into c…
VEZY Jan 12, 2026
dbc97c3
Fix zzz.R
vrahier Jan 12, 2026
a718bc9
fix: added gh4x >= 0.3.1 in Description file (#116)
sbuis Jan 12, 2026
148db73
fix adding line regression per version per sit
cyrillemidingoyi Jan 13, 2026
f7bd75c
Fix to display the 0.0 for residual plots
vrahier Jan 13, 2026
98ba7c2
fix plot shape=sit-text
cyrillemidingoyi Jan 13, 2026
2a9784d
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
cyrillemidingoyi Jan 13, 2026
4b1bf3a
Merge 2a9784d61b30ebf65a8775e08b289a4558398d3a into 8090d060d63302988…
VEZY Jan 13, 2026
3748916
Style code (GHA)
cyrillemidingoyi Jan 13, 2026
fabb320
Update specific_plotting_dynamic.R
VEZY Jan 13, 2026
cb7cad9
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
VEZY Jan 13, 2026
c3d8a1a
fix adding line regression case of version all situations
cyrillemidingoyi Jan 13, 2026
dd6d847
fix adding line regression per version for mixture_versiont
cyrillemidingoyi Jan 13, 2026
93d2c39
fix title test plot 31
cyrillemidingoyi Jan 13, 2026
c034c08
Fix color of the error bars
vrahier Jan 13, 2026
2f22269
fix remove duplicated code
cyrillemidingoyi Jan 13, 2026
11e07be
Closes #117
VEZY Jan 13, 2026
8b8d872
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
VEZY Jan 13, 2026
e26fc9d
Merge 8b8d872226e1c1d736ffdf828aa0a1afdea42b78 into 8090d060d63302988…
VEZY Jan 13, 2026
a4e4ee3
Style code (GHA)
VEZY Jan 13, 2026
b15f4d1
update dynamic test script
cyrillemidingoyi Jan 13, 2026
cab0d96
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
cyrillemidingoyi Jan 13, 2026
a7bb1dd
update legend mixture version without dominance
cyrillemidingoyi Jan 13, 2026
9c26b03
Re-organize the sections + add section for cropr_simulation (continue…
VEZY Jan 13, 2026
71a9753
fix Set the color of situation names according to the version
cyrillemidingoyi Jan 14, 2026
c54b7e6
docs: update functions doc (#123)
sbuis Jan 14, 2026
4772050
Merge branch 'code-refactoring' of https://github.com/SticsRPacks/Cro…
sbuis Jan 14, 2026
edb6a9b
Fix Ylim for plot of residues
vrahier Jan 14, 2026
b106e87
Build data on the fly and put it on a RData that users can import + m…
VEZY Jan 14, 2026
b5e27c9
Remove useless code
vrahier Jan 14, 2026
28e702f
Update TOC + add intercrops + put data structure section further down
VEZY Jan 14, 2026
8cc23e5
Update README.Rmd
VEZY Jan 14, 2026
853cf5b
Update README.Rmd
VEZY Jan 14, 2026
7b2030c
Update README.Rmd
VEZY Jan 14, 2026
0d09665
Fix extract plot
vrahier Jan 16, 2026
fb4b9bf
Fix incorrect links
sbuis Jan 17, 2026
97d1e08
Improve README comments (#111)
sbuis Jan 17, 2026
728588d
refactor: improve realism of synthetic data generation (#111)
sbuis Jan 18, 2026
35abf11
refactor: update example dataset (#111)
sbuis Jan 18, 2026
3ed9db7
refactor: simulated data was saved instead of recomputed for sake of …
sbuis Jan 18, 2026
d019b82
refactor: simulated data saved instead of recomputed for sake of simp…
sbuis Jan 18, 2026
fe4611c
refactor: improved illustration of group comparison (#111)
sbuis Jan 18, 2026
c9b4248
refactor: update stored figures (#111)
sbuis Jan 18, 2026
35515b3
Merge branch 'improving-readme' of https://github.com/SticsRPacks/Cro…
sbuis Jan 19, 2026
b6ccf2f
Merge branch 'code-refactoring' into improving-readme
sbuis Jan 19, 2026
c75948c
Merge branch 'code-refactoring' into improving-readme
vrahier Jan 21, 2026
7437ccb
docs: fix broken links in README
sbuis Jan 21, 2026
f40f130
docs: improved text in README
sbuis Jan 21, 2026
427e14a
docs: simplify standard deviation data handling
sbuis Jan 21, 2026
d8fd05c
docs: added Valentine in list of contributors
sbuis Jan 21, 2026
7ed86d5
Fix scatterplots axes limits after extract_plot
vrahier Jan 22, 2026
ffe1e85
Merge branch 'improving-readme' of https://github.com/SticsRPacks/Cro…
sbuis Jan 22, 2026
aeaff8c
docs: add example data for plot of standard deviation
sbuis Jan 22, 2026
125c4a1
docs: update README.md
sbuis Jan 22, 2026
e63423e
Merge pull request #128 from SticsRPacks/improving-readme
sbuis Jan 22, 2026
163f03f
Merge e63423e314b3e6e54d6f3310edf8a62cb1c85bd8 into 8090d060d63302988…
VEZY Jan 22, 2026
229f2db
Style code (GHA)
sbuis Jan 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,9 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: rc
# about pak-version:
# Ubuntu doesn't install the proper version of XML see https://github.com/r-lib/actions/issues/559. Remove when fixed.
# see also: https://stackoverflow.com/questions/73243945/pkgdown-action-failing-at-build-xml
# Temporarily forcing ggplot2 to v3.5.2 on main branch (see https://github.com/SticsRPacks/CroPlotR/issues/84)
extra-packages: |
any::rcmdcheck
SticsRPacks/SticsRFiles@main
ggplot2@3.5.2
needs: check

- uses: r-lib/actions/check-r-package@v2
Expand All @@ -77,8 +71,7 @@ jobs:
repository: SticsRPacks/SticsRTests
event-type: R-CMD-check
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "repo": "${{ github.event.repository.name }}"}'

- name: Wait for SticsRTests workflow to complete (block-and-fail)
- name: Wait for SticsRTests workflow to complete (block-and-fail)
uses: actions/github-script@v6
with:
github-token: ${{ secrets.TRIGGER_PAT }}
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ jobs:
extra-packages: any::covr
needs: coverage

- name: Force ggplot2 version 3.5.2
run: |
install.packages("remotes")
remotes::install_version("ggplot2", version = "3.5.2", upgrade = "never")
shell: Rscript {0}

- name: Test coverage
run: |
covr::codecov(
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/vdiffr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
snapshot_comparison:
runs-on: ubuntu-latest # Replace with the appropriate runner for your needs
runs-on: ubuntu-latest # Replace with the appropriate runner for your needs

steps:
- name: Checkout repository
Expand All @@ -18,18 +18,12 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
pak-version: rc
# about pak-version:
# Ubuntu doesn't install the proper version of XML see https://github.com/r-lib/actions/issues/559. Remove when fixed.
# see also: https://stackoverflow.com/questions/73243945/pkgdown-action-failing-at-build-xml
# Temporarily forcing ggplot2 to v3.5.2 on main branch (see https://github.com/SticsRPacks/CroPlotR/issues/84)
extra-packages: |
any::testthat
any::rcmdcheck
any::remotes
any::vdiffr
any::zip
ggplot2@3.5.2
SticsRPacks/SticsRFiles@main
needs: check

Expand All @@ -39,7 +33,8 @@ jobs:
Rscript -e "pkg_version <- 'Latest'; tmpdir <- '${{ runner.temp }}'; testthat::test_file('tests/testthat/test-dynamic-plots.R', stop_on_failure=FALSE); testthat::test_file('tests/testthat/test-scatter-plots.R', stop_on_failure=FALSE)"

- name: Cache the snapshot scripts
run: | # Move the scripts and data from tests/testthat to the tmpdir directory so that both run use the same scripts
run:
| # Move the scripts and data from tests/testthat to the tmpdir directory so that both run use the same scripts
mv tests/testthat/* ${{ runner.temp }}/

- name: Checkout CroPlotR main branch
Expand All @@ -66,4 +61,3 @@ jobs:
- name: Compare snapshots
run: |
Rscript -e "tmpdir <- '${{ runner.temp }}'; testthat::test_file('${{ runner.temp }}/vdiffr/test-snapshots.R', stop_on_failure=TRUE)"

4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Authors@R: c(
comment = c(ORCID = "0000-0002-4044-4322")),
person("Michel", "Giner", , "michel.giner@cirad.fr", role = "aut",
comment = c(ORCID = "0000-0002-9310-2377")),
person("Valentine", "Rahier", role = "ctb"),
person("Amine", "Barkaoui", role = "ctb"),
person("Patrick", "Lutz", role = "ctb")
)
Expand All @@ -36,6 +37,7 @@ Depends:
Imports:
cli,
dplyr,
ggh4x (>= 0.3.1),
ggplot2,
ggrepel,
gridExtra,
Expand All @@ -57,4 +59,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ importFrom(parallel,parLapply)
importFrom(parallel,stopCluster)
importFrom(plyr,join_all)
importFrom(reshape2,melt)
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(stats,cor)
importFrom(stats,lm)
Expand All @@ -75,4 +76,3 @@ importFrom(stats,qt)
importFrom(stats,sd)
importFrom(stats,var)
importFrom(tidyselect,vars_select_helpers)
importFrom(utils,head)
147 changes: 64 additions & 83 deletions R/aesthetics.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
#' Template aesthetics
#'
#' This function returns a template list of aesthetics for a plot, including
#' color, shape, linetype, and group.
#'
#' @return A list of aesthetics for a plot.
#'
#' @keywords internal
template_aesthetics <- function() {
aesthetics <- list(
"plot" = list(
"color" = list(NULL), "shape" = list(NULL),
"linetype" = list(NULL), "group" = list(NULL)
),
"versions" = list("shape" = list(NULL), "linetype" = list(NULL))
)
return(aesthetics)
}
#' Detects if a situation is a mixture
#'
#' This function checks if the situation is a mixture based on
#' the presence of a column named "Dominance" and the uniqueness
#' of its values.
#'
#' @param sim_situation A data frame containing the simulated data for
#' one situation.
#' @return A logical value indicating if the situation is a mixture.
#' @examples
#' \dontrun{
#' sim_data <- data.frame(
#' Dominance = c("Principal", "Principal", "Associated", "Associated")
#' )
#' CroPlotR:::detect_mixture(sim_data)
#' # Output: TRUE
#'
#' sim_data <- data.frame(Dominance = c("Single Crop", "Single Crop"))
#' CroPlotR:::detect_mixture(sim_data)
#' # Output: FALSE
#'
#' sim_data <- data.frame(lai = c(1, 1.2))
#' CroPlotR:::detect_mixture(sim_data)
#' # Output: FALSE
#' }
detect_mixture <- function(sim_situation) {
is_Dominance <- grep("Dominance", x = colnames(sim_situation), fixed = TRUE)
if (length(is_Dominance) > 0) {
is_mixture <- length(unique(sim_situation[[is_Dominance]])) > 1
} else {
is_mixture <- FALSE
}

return(is_mixture)
}

#' Detect items cases
#' Detect items cases for dynamic plots
#'
#' This function detects the cases for computing the aesthetics of a plot based on
#' whether it is a mixture or not, whether it has one or multiple versions, and
Expand Down Expand Up @@ -46,94 +62,59 @@ detect_mixture_version_overlap <- function(is_mixture, one_version, overlap) {
return(case)
}

#' Detect items cases
#' Detect items cases for scatter plots
#'
#' This function detects the cases for computing the aesthetics of a plot based on
#' whether it is a mixture or not, whether it has one or multiple versions, and
#' whether there are one or several situations to plot into the same plot.
#'
#' @param is_mixture A logical value indicating whether the crop is a mixture or not.
#' @param one_version A logical value indicating whether the plot has one or multiple versions (e.g. of the model).
#' @param several_sit A logical value indicating whether there are one or several situations to plot.
#' @param has_distinct_situations A logical value indicating whether there are one or several situations to plot.
#'
#' @return A character string indicating the case for computing the aesthetics of the plot.
#'
#' @keywords internal
detect_mixture_version_situations <- function(is_mixture, one_version, several_sit) {
case <- switch(paste(is_mixture, !one_version, several_sit),
"TRUE TRUE TRUE" = "mixture_versions_situations",
"TRUE TRUE FALSE" = "mixture_versions_no_situations",
"TRUE FALSE TRUE" = "mixture_no_versions_situations",
"TRUE FALSE FALSE" = "mixture_no_versions_no_situations",
detect_mixture_version_situations <- function(is_mixture, one_version, has_distinct_situations) {
case <- switch(paste(is_mixture, !one_version, has_distinct_situations),
"TRUE TRUE TRUE" = "mixture_versions",
"TRUE TRUE FALSE" = "mixture_versions",
"TRUE FALSE TRUE" = "mixture_no_versions",
"TRUE FALSE FALSE" = "mixture_no_versions",
"FALSE TRUE TRUE" = "non_mixture_versions_situations",
"FALSE TRUE FALSE" = "non_mixture_versions_no_situations",
"FALSE TRUE FALSE" = "non_mixture_versions_per_situations",
"FALSE FALSE TRUE" = "non_mixture_no_versions_situations",
"FALSE FALSE FALSE" = "non_mixture_no_versions_no_situations"
"FALSE FALSE FALSE" = "non_mixture_no_versions_per_situations"
)

return(case)
}

#' Manages the aesthetics of the graphics
#'
#' @description Manages the shape, color and line type of the graphics according
#' to their content
#'
#' @param sim A simulation list of data.frames
#' @param obs An observation list of data.frames
#' @param type The type of plot required, either "dynamic" or "scatter"
#' @param overlap A list of lists containing the variables to represent on the
#' same graph when `type = "dynamic"`
#' @param several_sit Boolean. Must be equal to `TRUE` if sim and obs gather
#' more than one situation and if situations should be differentiated
#' on the graph.
#' @param shape_sit Shape to differentiate between situations when
#' `all_situations= TRUE`. See details.
#' @param one_version Boolean. Must be `TRUE` if several versions will be
#' plotted on the same graph.
#' @param iVersion Integer. Version number of sim
#' @param dot_args List of dot arguments given to plot function
#'
#' @details The `shape_sit` argument can be:
#' * "none" (the default): Same shape for all situations.
#' * "txt": Writes the name of the situation above each point.
#' * "symbol": One shape for each situation.
#' * "group": One shape for each group of situations described in
#' `situation_group`.
#'
#' @return An aesthetics expression which will allow to manage the aesthetics
#' of the graphics
#' Detect items cases
#'
#' @keywords internal
#' This function returns a unique string based on the type of plot, and
#' whether the situation is a mixture or not, if there is one or multiple
#' versions to plot, and if there is one or several situations to plot
#' into the same plot.
#' The output is used to choose the right plotting function in a switch.
#'
aesthetics <- function(sim, obs = NULL, type = c("dynamic", "scatter"),
overlap = NULL, several_sit = FALSE,
shape_sit = c("none", "txt", "symbol", "group"),
one_version = TRUE, iVersion = 1,
dot_args = NULL) {
is_dominance <- grep("Dominance", x = colnames(sim), fixed = TRUE)
if (length(is_dominance) > 0) {
is_mixture <- length(unique(sim[[is_dominance]])) > 1
} else {
is_mixture <- FALSE
}
is_mixture <- is_mixture && (length(unique(sim$Dominance)) > 1)

aesthetics <- template_aesthetics()

#' @param type The type of plot required, either 'dynamic' or 'scatter
#' @param is_mixture A logical value indicating whether the crop is a mixture or not.
#' @param one_version A logical value indicating whether the plot has one or multiple versions (e.g. of the model).
#' @param has_distinct_situations A logical value indicating whether there are one or several situations to plot.
#' @param overlap A logical value indicating whether there is any overlapping variables in the plot.
#'
#' @return A unique character string for the plot.
#'
#' @keywords internal
detect_item_case <- function(type, is_mixture, one_version, has_distinct_situations, overlap) {
if (type == "dynamic") {
aesthetics <- aesthetics_dynamic(
sim, aesthetics, overlap, one_version, iVersion, dot_args,
is_mixture
)
item_case <- detect_mixture_version_overlap(is_mixture, one_version, overlap)
} else if (type == "scatter") {
aesthetics <- aesthetics_scatter(
sim, aesthetics, overlap, several_sit, one_version, iVersion,
dot_args, is_mixture
)
item_case <- detect_mixture_version_situations(is_mixture, one_version, has_distinct_situations)
} else {
stop("type must be either 'dynamic' or 'scatter'")
}

return(aesthetics)
return(item_case)
}
74 changes: 0 additions & 74 deletions R/aesthetics_dynamic.R

This file was deleted.

Loading