Closed yanxianl closed 6 years ago
Hi,
I just fixed the problem by moving the aes(fill = forcats::fct_rev(Rank)) from the global aesthetics to the local aesthetics in geom_bar(). Namely:
ggplot(df, aes(Diet, Percent)) + geom_bar(aes(fill = forcats::fct_rev(Rank)), stat = "identity") # forcats::fct_rev() reverses stacked bars
Cheers, Yanxian
Hi,
First of all, thank you for developing and maintaining the ggsignif !
I was trying to add significant p values to a faceted stacked bar plot but kept getting an error message saying
Below are the data and code to reproduce my problem:
Created on 2018-11-05 by the reprex package (v0.2.1)
Session info
``` r devtools::session_info() #> - Session info ---------------------------------------------------------- #> setting value #> version R version 3.4.3 (2017-11-30) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate Chinese (Simplified)_China.936 #> ctype Chinese (Simplified)_China.936 #> tz Europe/Berlin #> date 2018-11-05 #> #> - Packages -------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.0 2017-04-11 [1] CRAN (R 3.4.4) #> backports 1.1.2 2017-12-13 [1] CRAN (R 3.4.3) #> base64enc 0.1-3 2015-07-28 [1] CRAN (R 3.4.1) #> bindr 0.1.1 2018-03-13 [1] CRAN (R 3.4.4) #> bindrcpp 0.2.2 2018-03-29 [1] CRAN (R 3.4.4) #> broom 0.5.0 2018-07-17 [1] CRAN (R 3.4.3) #> callr 3.0.0 2018-08-24 [1] CRAN (R 3.4.4) #> cellranger 1.1.0 2016-07-27 [1] CRAN (R 3.4.4) #> cli 1.0.1 2018-09-25 [1] CRAN (R 3.4.4) #> colorspace 1.3-2 2016-12-14 [1] CRAN (R 3.4.4) #> cowplot * 0.9.3 2018-07-15 [1] CRAN (R 3.4.4) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.4.4) #> curl 3.2 2018-03-28 [1] CRAN (R 3.4.4) #> debugme 1.1.0 2017-10-22 [1] CRAN (R 3.4.4) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.4.4) #> devtools 2.0.0 2018-10-19 [1] CRAN (R 3.4.3) #> digest 0.6.18 2018-10-10 [1] CRAN (R 3.4.4) #> dplyr * 0.7.7 2018-10-16 [1] CRAN (R 3.4.4) #> evaluate 0.12 2018-10-09 [1] CRAN (R 3.4.4) #> forcats * 0.3.0 2018-02-19 [1] CRAN (R 3.4.4) #> fs 1.2.6 2018-08-23 [1] CRAN (R 3.4.4) #> ggplot2 * 3.1.0 2018-10-25 [1] CRAN (R 3.4.4) #> ggsignif * 0.4.0 2017-08-03 [1] CRAN (R 3.4.4) #> glue 1.3.0 2018-07-17 [1] CRAN (R 3.4.4) #> gtable 0.2.0 2016-02-26 [1] CRAN (R 3.4.4) #> haven 1.1.2 2018-06-27 [1] CRAN (R 3.4.4) #> hms 0.4.2 2018-03-10 [1] CRAN (R 3.4.4) #> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.4.4) #> httr 1.3.1 2017-08-20 [1] CRAN (R 3.4.4) #> jsonlite 1.5 2017-06-01 [1] CRAN (R 3.4.4) #> knitr 1.20 2018-02-20 [1] CRAN (R 3.4.4) #> lattice 0.20-35 2017-03-25 [2] CRAN (R 3.4.3) #> lazyeval 0.2.1 2017-10-29 [1] CRAN (R 3.4.4) #> lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.4.4) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.4.4) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.4.4) #> mime 0.6 2018-10-05 [1] CRAN (R 3.4.4) #> modelr 0.1.2 2018-05-11 [1] CRAN (R 3.4.4) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.4.4) #> nlme 3.1-137 2018-04-07 [1] CRAN (R 3.4.4) #> pillar 1.3.0 2018-07-14 [1] CRAN (R 3.4.4) #> pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.4.3) #> pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.4.4) #> pkgload 1.0.1 2018-10-11 [1] CRAN (R 3.4.4) #> plyr 1.8.4 2016-06-08 [1] CRAN (R 3.4.4) #> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.4.4) #> processx 3.2.0 2018-08-16 [1] CRAN (R 3.4.4) #> ps 1.1.0 2018-08-10 [1] CRAN (R 3.4.4) #> purrr * 0.2.5 2018-05-29 [1] CRAN (R 3.4.4) #> R6 2.3.0 2018-10-04 [1] CRAN (R 3.4.4) #> Rcpp 0.12.19 2018-10-01 [1] CRAN (R 3.4.4) #> readr * 1.1.1 2017-05-16 [1] CRAN (R 3.4.4) #> readxl 1.1.0 2018-04-20 [1] CRAN (R 3.4.4) #> remotes 2.0.1 2018-10-19 [1] CRAN (R 3.4.3) #> rlang 0.2.2 2018-08-16 [1] CRAN (R 3.4.4) #> rmarkdown 1.10 2018-06-11 [1] CRAN (R 3.4.4) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.4.4) #> rvest 0.3.2 2016-06-17 [1] CRAN (R 3.4.4) #> scales 1.0.0 2018-08-09 [1] CRAN (R 3.4.4) #> sessioninfo 1.1.0 2018-09-25 [1] CRAN (R 3.4.4) #> stringi 1.1.7 2018-03-12 [1] CRAN (R 3.4.4) #> stringr * 1.3.1 2018-05-10 [1] CRAN (R 3.4.4) #> testthat 2.0.1 2018-10-13 [1] CRAN (R 3.4.4) #> tibble * 1.4.2 2018-01-22 [1] CRAN (R 3.4.4) #> tidyr * 0.8.1 2018-05-18 [1] CRAN (R 3.4.4) #> tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.4.4) #> tidyverse * 1.2.1 2017-11-14 [1] CRAN (R 3.4.4) #> usethis 1.4.0 2018-08-14 [1] CRAN (R 3.4.4) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.4.4) #> xml2 1.2.0 2018-01-24 [1] CRAN (R 3.4.4) #> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.4.4) #> #> [1] C:/Users/ljt89/Documents/R/win-library/3.4 #> [2] C:/Program Files/R/R-3.4.3/library ```