Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outline colors now sensitive to user-specific factorLevel order #262

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
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
17 changes: 2 additions & 15 deletions R/raincloudPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,12 @@ raincloudPlotsInternal <- function(jaspResults, dataset, options) {
if (options[["secondaryFactor"]] != "") {
nSecondaryLevels <- nlevels(onlyFactors$secondaryFactor)
levelColors <- jaspGraphs::JASPcolors(palette = options[["colorPalette"]], asFunction = TRUE)(nSecondaryLevels)

# levelColors are in alphabetical order of levels, not in input order with which JASP user enters them
# So, we have to rearrange them from alphabetical to input order
levelsActualOrder <- levels(onlyFactors$secondaryFactor)
levelsAlphabetical <- sort(levelsActualOrder) # This is the order for levelColors
reorderedLevelColors <- levelColors[match(levelsActualOrder, levelsAlphabetical)]

possibleCombis$color <- rep(reorderedLevelColors, nlevels(onlyFactors$primaryFactor))
possibleCombis$color <- levelColors

} else if (options[["colorAnyway"]]) {
nPrimaryLevels <- nlevels(onlyFactors$primaryFactor)
levelColors <- jaspGraphs::JASPcolors(palette = options[["colorPalette"]], asFunction = TRUE)(nPrimaryLevels)

# See previous if-statement for explanation of following
levelsActualOrder <- levels(onlyFactors$primaryFactor)
levelsAlphabetical <- sort(levelsActualOrder)
reorderedLevelColors <- levelColors[match(levelsActualOrder, levelsAlphabetical)]

possibleCombis$color <- reorderedLevelColors
possibleCombis$color <- levelColors

} else {
possibleCombis$color <- "black" # Is not used further
Expand Down
Loading