corybrunson / ggalluvial

ggplot2 extension for alluvial plots
http://corybrunson.github.io/ggalluvial/
GNU General Public License v3.0
497 stars 34 forks source link

Breaks with new thematic auto theme package #78

Closed elfatherbrown closed 3 years ago

elfatherbrown commented 3 years ago

Description of the issue

Hi. Not sure if this is a bug or what, but the thematic package is really very nice and it would be very cool for it to work with your life-saving package for alluvial plots. Ill be posting the same to thematic's issues. Maybe there will be some interest.

Reprex

library(ggalluvial)
#> Loading required package: ggplot2
#Works!
ggplot(as.data.frame(Titanic),
       aes(y = Freq,
           axis1 = Class, axis2 = Sex, axis3 = Age,
           fill = Survived)) +
    geom_alluvium() +
    scale_x_discrete(limits = c("Class", "Sex", "Age"))

# :(
# Sniff.... 
thematic::thematic_on("black","lightgray",accent="white")
#> This version of thematic is designed to work with rmarkdown version 2.6.6 or higher. Consider upgrading via remotes::install_github('rstudio/rmarkdown')
ggplot(as.data.frame(Titanic),
       aes(y = Freq,
           axis1 = Class, axis2 = Sex, axis3 = Age,
           fill = Survived)) +
    geom_alluvium() +
    scale_x_discrete(limits = c("Class", "Sex", "Age"))
#> Error in col2rgb(color, alpha = TRUE): numerical color values must be positive

#... :~(

Created on 2021-02-25 by the reprex package (v1.0.0)

Sessioninfo


─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.3 (2020-02-29)
 os       Ubuntu 20.04.2 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/Mazatlan            
 date     2021-02-25                  

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       lib source        
 assertthat    0.2.1   2019-03-21 [3] CRAN (R 3.6.1)
 callr         3.5.1   2020-10-13 [1] CRAN (R 3.6.3)
 cli           2.3.0   2021-01-31 [1] CRAN (R 3.6.3)
 clipr         0.7.0   2019-07-23 [3] CRAN (R 3.6.1)
 crayon        1.4.1   2021-02-08 [1] CRAN (R 3.6.3)
 desc          1.2.0   2018-05-01 [3] CRAN (R 3.5.0)
 devtools      2.2.2   2020-02-17 [3] CRAN (R 3.6.3)
 digest        0.6.27  2020-10-24 [1] CRAN (R 3.6.3)
 ellipsis      0.3.1   2020-05-15 [1] CRAN (R 3.6.3)
 evaluate      0.14    2019-05-28 [3] CRAN (R 3.6.1)
 fs            1.3.1   2019-05-06 [3] CRAN (R 3.6.3)
 glue          1.4.2   2020-08-27 [1] CRAN (R 3.6.3)
 highr         0.8     2019-03-20 [3] CRAN (R 3.6.1)
 htmltools     0.4.0   2019-10-04 [3] CRAN (R 3.6.3)
 knitr         1.28    2020-02-06 [3] CRAN (R 3.6.2)
 magrittr      2.0.1   2020-11-17 [1] CRAN (R 3.6.3)
 memoise       1.1.0   2017-04-21 [3] CRAN (R 3.5.0)
 pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 3.6.3)
 pkgload       1.1.0   2020-05-29 [1] CRAN (R 3.6.3)
 prettyunits   1.1.1   2020-01-24 [3] CRAN (R 3.6.2)
 processx      3.4.5   2020-11-30 [1] CRAN (R 3.6.3)
 ps            1.5.0   2020-12-05 [1] CRAN (R 3.6.3)
 R6            2.5.0   2020-10-28 [1] CRAN (R 3.6.3)
 Rcpp          1.0.3   2019-11-08 [3] CRAN (R 3.6.3)
 remotes       2.1.1   2020-02-15 [3] CRAN (R 3.6.2)
 reprex        1.0.0   2021-01-27 [1] CRAN (R 3.6.3)
 rlang         0.4.10  2020-12-30 [1] CRAN (R 3.6.3)
 rmarkdown     2.1     2020-01-20 [3] CRAN (R 3.6.2)
 rprojroot     2.0.2   2020-11-15 [1] CRAN (R 3.6.3)
 rstudioapi    0.13    2020-11-12 [1] CRAN (R 3.6.3)
 sessioninfo   1.1.1   2018-11-05 [3] CRAN (R 3.5.1)
 testthat      3.0.2   2021-02-14 [1] CRAN (R 3.6.3)
 usethis       1.5.1   2019-07-04 [3] CRAN (R 3.6.2)
 withr         2.4.1   2021-01-26 [1] CRAN (R 3.6.3)
 xfun          0.12    2020-01-13 [3] CRAN (R 3.6.2)
 yaml          2.2.1   2020-02-01 [3] CRAN (R 3.6.2)

[1] /home/alex/R/x86_64-pc-linux-gnu-library/3.6
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library

corybrunson commented 3 years ago

@elfatherbrown thanks! I was not aware of the thematic package. I'll want to have a closer look at it before attempting to address the issue, so please allow a few days for a detailed response. Thanks for raising it.

cpsievert commented 3 years ago

Looks like this has something to do with the use of colour = 0, is that a valid thing? If so, what colour value does it represent? Maybe transparent?

▶ ag 'colour = 0'                         
R/geom-alluvium.r
82:                    colour = 0, fill = "gray", alpha = .5),

R/geom-flow.r
72:                    colour = 0, fill = "gray", alpha = .5),

R/geom-lode.r
58:                    colour = 0, fill = "gray", alpha = .5),
cpsievert commented 3 years ago

I just pushed a fix to thematic for this -- I'm guessing that colour = 0 is equivalent to colour = NA (or colour = "transparent"), but let me know if that's a bad assumption

corybrunson commented 3 years ago

@cpsievert interesting! Thanks. Maybe it was previously but is no longer (having tried a couple of example plots using ggplot2), but it still works within ggalluvial and i don't offhand know why. A new version will be out soon, and i'll make sure to switch the defaults to "transparent" (and stop misinterpreting 0) in that release.

corybrunson commented 3 years ago

I'd like to better understand why colour = "transparent" has the same effect as colour = 0, but that colour = NA (as recommended in the ggplot2 reference) has the effect of erasing (or making transparent?) the interiors of the graphical elements, which should be controlled by fill, as well as their borders, which are controlled by colour.

That said, i can still replace 0 with "transparent", which is more clear to the user and consistent with other packages.