Order of colored marginal boxplots to not match the order of the color factor used
alanzos opened this issue · 3 comments
Hi, thanks for this amazing package.
I noticed that the marginal boxplots do not respect the order of the color factor.
See the example in your shiny app (https://daattali.com/shiny/ggExtra-ggMarginal-demo/):
The order on the top is blue, red, and green.
While the order on the left is green, blue, and red.
And the order of the "Class" factor is red, green, and blue.
Is this intentional or a bug?
Thanks in advance,
Andrés.
Thanks for the report! You're right about this issue, I never noticed it. It's not intentional. However, this package is mostly in maintenance mode, meaning that if something breaks horribly I'll invest the time to investigate and fix, but for any new features/minor bug fixes, I personally am unlikely to do it. If you or anyone else wants to look into this and submit a PR, I'll be very happy to help get it merged!
Hey @alanzos , can you try installing the latest version of ggExtra and see if that fixes your issue?
New version
library(ggExtra)
library(ggplot2)
p <- ggplot(`iris`, aes_string('Sepal.Length', 'Sepal.Width')) +
aes_string(colour = 'Species') +
geom_point() + theme_bw(15)
#> Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
#> ℹ Please use tidy evaluation idioms with `aes()`.
#> ℹ See also `vignette("ggplot2-in-packages")` for more information.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
ggMarginal(
p,
type = 'boxplot',
margins = 'both',
size = 5,
colour = '#FF0000',
groupFill = TRUE
)
sessioninfo::session_info(pkgs = 'attached')
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.4.1 (2024-06-14)
#> os macOS Sonoma 14.4
#> system aarch64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2024-08-06
#> pandoc 3.1.11 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> ggExtra * 0.10.1 2023-08-21 [1] CRAN (R 4.4.0)
#> ggplot2 * 3.5.1 2024-04-23 [1] CRAN (R 4.4.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
Created on 2024-08-06 with reprex v2.1.1
Old version
Note I installed it from Github on 8/7/2024, that's not when this version - 0.10.0 - was released though
devtools::install_github(
"daattali/ggExtra", ref = "c0491d9a69ee3bfacc6f6a7efe92cc3b084049c8"
)
#> Downloading GitHub repo daattali/ggExtra@c0491d9a69ee3bfacc6f6a7efe92cc3b084049c8
#>
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> * checking for file ‘/private/var/folders/z0/d9xfj6_524jct47tt216fjkr0000gn/T/RtmpoaNnYs/remotesafdc6519e81c/daattali-ggExtra-c0491d9/DESCRIPTION’ ... OK
#> * preparing ‘ggExtra’:
#> * checking DESCRIPTION meta-information ... OK
#> * checking for LF line-endings in source and make files and shell scripts
#> * checking for empty or unneeded directories
#> * building ‘ggExtra_0.10.0.tar.gz’
library(ggExtra)
library(ggplot2)
p <- ggplot(`iris`, aes_string('Sepal.Length', 'Sepal.Width')) +
aes_string(colour = 'Species') +
geom_point() + theme_bw(15)
#> Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
#> ℹ Please use tidy evaluation idioms with `aes()`.
#> ℹ See also `vignette("ggplot2-in-packages")` for more information.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
ggMarginal(
p,
type = 'boxplot',
margins = 'both',
size = 5,
colour = '#FF0000',
groupFill = TRUE
)
sessioninfo::session_info(pkgs = 'attached')
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.4.1 (2024-06-14)
#> os macOS Sonoma 14.4
#> system aarch64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2024-08-06
#> pandoc 3.1.11 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> ggExtra * 0.10.0 2024-08-07 [1] Github (daattali/ggExtra@c0491d9)
#> ggplot2 * 3.5.1 2024-04-23 [1] CRAN (R 4.4.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
Created on 2024-08-06 with reprex v2.1.1