├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ └── pkgdown.yaml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DESCRIPTION ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── R ├── continuous-bs5.R ├── continuous-gsea.R ├── continuous-material.R ├── continuous-tw3.R ├── discrete-aaas.R ├── discrete-bmj.R ├── discrete-cosmic.R ├── discrete-d3.R ├── discrete-flatui.R ├── discrete-frontiers.R ├── discrete-futurama.R ├── discrete-igv.R ├── discrete-jama.R ├── discrete-jco.R ├── discrete-lancet.R ├── discrete-locuszoom.R ├── discrete-nejm.R ├── discrete-npg.R ├── discrete-observable.R ├── discrete-rickandmorty.R ├── discrete-simpsons.R ├── discrete-startrek.R ├── discrete-tron.R ├── discrete-uchicago.R ├── discrete-ucscgb.R ├── ggsci-package.R ├── palettes.R └── utils.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── ggsci.Rproj ├── inst ├── WORDLIST └── logo │ └── logo.R ├── man ├── figures │ ├── README-ggsci-aaas-1.png │ ├── README-ggsci-bmj-1.png │ ├── README-ggsci-bs5-1.png │ ├── README-ggsci-cosmic-1.png │ ├── README-ggsci-cosmic-2.png │ ├── README-ggsci-cosmic-3.png │ ├── README-ggsci-d3-1.png │ ├── README-ggsci-flatui-1.png │ ├── README-ggsci-frontiers-1.png │ ├── README-ggsci-futurama-1.png │ ├── README-ggsci-gsea-1.png │ ├── README-ggsci-igv-1.png │ ├── README-ggsci-jama-1.png │ ├── README-ggsci-jco-1.png │ ├── README-ggsci-lancet-1.png │ ├── README-ggsci-locuszoom-1.png │ ├── README-ggsci-material-1.png │ ├── README-ggsci-nejm-1.png │ ├── README-ggsci-npg-1.png │ ├── README-ggsci-observable-1.png │ ├── README-ggsci-rickandmorty-1.png │ ├── README-ggsci-simpsons-1.png │ ├── README-ggsci-startrek-1.png │ ├── README-ggsci-tron-1.png │ ├── README-ggsci-tw3-1.png │ ├── README-ggsci-uchicago-1.png │ ├── README-ggsci-ucscgb-1.png │ └── logo.png ├── ggsci-package.Rd ├── pal_aaas.Rd ├── pal_bmj.Rd ├── pal_bs5.Rd ├── pal_cosmic.Rd ├── pal_d3.Rd ├── pal_flatui.Rd ├── pal_frontiers.Rd ├── pal_futurama.Rd ├── pal_gsea.Rd ├── pal_igv.Rd ├── pal_jama.Rd ├── pal_jco.Rd ├── pal_lancet.Rd ├── pal_locuszoom.Rd ├── pal_material.Rd ├── pal_nejm.Rd ├── pal_npg.Rd ├── pal_observable.Rd ├── pal_rickandmorty.Rd ├── pal_simpsons.Rd ├── pal_startrek.Rd ├── pal_tron.Rd ├── pal_tw3.Rd ├── pal_uchicago.Rd ├── pal_ucscgb.Rd ├── rgb_bs5.Rd ├── rgb_gsea.Rd ├── rgb_material.Rd ├── rgb_tw3.Rd ├── scale_aaas.Rd ├── scale_bmj.Rd ├── scale_bs5.Rd ├── scale_cosmic.Rd ├── scale_d3.Rd ├── scale_flatui.Rd ├── scale_frontiers.Rd ├── scale_futurama.Rd ├── scale_gsea.Rd ├── scale_igv.Rd ├── scale_jama.Rd ├── scale_jco.Rd ├── scale_lancet.Rd ├── scale_locuszoom.Rd ├── scale_material.Rd ├── scale_nejm.Rd ├── scale_npg.Rd ├── scale_observable.Rd ├── scale_rickandmorty.Rd ├── scale_simpsons.Rd ├── scale_startrek.Rd ├── scale_tron.Rd ├── scale_tw3.Rd ├── scale_uchicago.Rd └── scale_ucscgb.Rd ├── pkgdown └── favicon │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico └── vignettes ├── custom.css ├── ggsci-faq.Rmd └── ggsci.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | 4 | ^\.github$ 5 | ^_pkgdown\.yml$ 6 | ^pkgdown$ 7 | ^docs$ 8 | 9 | ^CONTRIBUTING\.md$ 10 | ^CODE_OF_CONDUCT\.md$ 11 | ^LICENSE\.md$ 12 | ^README\.Rmd$ 13 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | 9 | name: R-CMD-check 10 | 11 | permissions: read-all 12 | 13 | jobs: 14 | R-CMD-check: 15 | runs-on: ${{ matrix.config.os }} 16 | 17 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 18 | 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | config: 23 | - {os: macos-latest, r: 'release'} 24 | - {os: windows-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 26 | - {os: ubuntu-latest, r: 'release'} 27 | - {os: ubuntu-latest, r: 'oldrel-1'} 28 | 29 | env: 30 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 31 | R_KEEP_PKG_SOURCE: yes 32 | 33 | steps: 34 | - uses: actions/checkout@v4 35 | 36 | - uses: r-lib/actions/setup-pandoc@v2 37 | 38 | - uses: r-lib/actions/setup-r@v2 39 | with: 40 | r-version: ${{ matrix.config.r }} 41 | http-user-agent: ${{ matrix.config.http-user-agent }} 42 | use-public-rspm: true 43 | 44 | - uses: r-lib/actions/setup-r-dependencies@v2 45 | with: 46 | extra-packages: any::rcmdcheck 47 | needs: check 48 | 49 | - uses: r-lib/actions/check-r-package@v2 50 | with: 51 | upload-snapshots: true 52 | build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' 53 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | release: 9 | types: [published] 10 | workflow_dispatch: 11 | 12 | name: pkgdown 13 | 14 | permissions: read-all 15 | 16 | jobs: 17 | pkgdown: 18 | runs-on: ubuntu-latest 19 | # Only restrict concurrency for non-PR jobs 20 | concurrency: 21 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 22 | env: 23 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 24 | permissions: 25 | contents: write 26 | steps: 27 | - uses: actions/checkout@v4 28 | 29 | - uses: r-lib/actions/setup-pandoc@v2 30 | 31 | - uses: r-lib/actions/setup-r@v2 32 | with: 33 | use-public-rspm: true 34 | 35 | - uses: r-lib/actions/setup-r-dependencies@v2 36 | with: 37 | extra-packages: any::pkgdown, local::. 38 | needs: website 39 | 40 | - name: Build site 41 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 42 | shell: Rscript {0} 43 | 44 | - name: Deploy to GitHub pages 🚀 45 | if: github.event_name != 'pull_request' 46 | uses: JamesIves/github-pages-deploy-action@v4.5.0 47 | with: 48 | clean: false 49 | branch: gh-pages 50 | folder: docs 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .DS_Store 5 | 6 | /docs/ 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to ggsci 2 | 3 | :+1::tada: First off, thanks for taking your time to contribute! :tada::+1: 4 | 5 | You could contribute to this project by: 6 | 7 | 1. Filing a bug report or feature request in an issue. 8 | 2. Suggesting a change via a pull request. 9 | 10 | ## Issues 11 | 12 | To file an issue about a possible bug, please try to include: 13 | 14 | - Relevant package versions 15 | - Necessary code and data to reproduce the issue 16 | 17 | ## Pull Requests 18 | 19 | To suggest a change via pull requests, please: 20 | 21 | 1. Fork the repository into your GitHub account. 22 | 2. Clone the forked repository to local machine, make the changes. 23 | 3. Commit and push the changes to GitHub. Create a pull request. 24 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: ggsci 2 | Type: Package 3 | Title: Scientific Journal and Sci-Fi Themed Color Palettes for 'ggplot2' 4 | Version: 3.2.0 5 | Authors@R: c( 6 | person("Nan", "Xiao", email = "me@nanx.me", role = c("aut", "cre"), 7 | comment = c(ORCID = "0000-0002-0250-5673")), 8 | person("Joshua", "Cook", email = "joshuacook0023@gmail.com", role = "ctb"), 9 | person("Clara", "Jégousse", email = "cat3@hi.is", role = "ctb"), 10 | person("Hui", "Chen", email = "huichen@zju.edu.cn", role = "ctb"), 11 | person("Miaozhu", "Li", email = "miaozhu.li@duke.edu", role = "ctb") 12 | ) 13 | Maintainer: Nan Xiao 14 | Description: A collection of 'ggplot2' color palettes inspired by 15 | plots in scientific journals, data visualization libraries, 16 | science fiction movies, and TV shows. 17 | License: GPL (>= 3) 18 | URL: https://nanx.me/ggsci/, https://github.com/nanxstats/ggsci 19 | BugReports: https://github.com/nanxstats/ggsci/issues 20 | Depends: 21 | R (>= 3.5.0) 22 | Imports: 23 | ggplot2 (>= 2.0.0), 24 | grDevices, 25 | scales 26 | Suggests: 27 | gridExtra, 28 | knitr, 29 | ragg, 30 | rmarkdown 31 | VignetteBuilder: knitr 32 | Encoding: UTF-8 33 | RoxygenNote: 7.3.1 34 | Roxygen: list(markdown = TRUE) 35 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(pal_aaas) 4 | export(pal_bmj) 5 | export(pal_bs5) 6 | export(pal_cosmic) 7 | export(pal_d3) 8 | export(pal_flatui) 9 | export(pal_frontiers) 10 | export(pal_futurama) 11 | export(pal_gsea) 12 | export(pal_igv) 13 | export(pal_jama) 14 | export(pal_jco) 15 | export(pal_lancet) 16 | export(pal_locuszoom) 17 | export(pal_material) 18 | export(pal_nejm) 19 | export(pal_npg) 20 | export(pal_observable) 21 | export(pal_rickandmorty) 22 | export(pal_simpsons) 23 | export(pal_startrek) 24 | export(pal_tron) 25 | export(pal_tw3) 26 | export(pal_uchicago) 27 | export(pal_ucscgb) 28 | export(rgb_bs5) 29 | export(rgb_gsea) 30 | export(rgb_material) 31 | export(rgb_tw3) 32 | export(scale_color_aaas) 33 | export(scale_color_bmj) 34 | export(scale_color_bs5) 35 | export(scale_color_cosmic) 36 | export(scale_color_d3) 37 | export(scale_color_flatui) 38 | export(scale_color_frontiers) 39 | export(scale_color_futurama) 40 | export(scale_color_gsea) 41 | export(scale_color_igv) 42 | export(scale_color_jama) 43 | export(scale_color_jco) 44 | export(scale_color_lancet) 45 | export(scale_color_locuszoom) 46 | export(scale_color_material) 47 | export(scale_color_nejm) 48 | export(scale_color_npg) 49 | export(scale_color_observable) 50 | export(scale_color_rickandmorty) 51 | export(scale_color_simpsons) 52 | export(scale_color_startrek) 53 | export(scale_color_tron) 54 | export(scale_color_tw3) 55 | export(scale_color_uchicago) 56 | export(scale_color_ucscgb) 57 | export(scale_colour_aaas) 58 | export(scale_colour_bmj) 59 | export(scale_colour_bs5) 60 | export(scale_colour_cosmic) 61 | export(scale_colour_d3) 62 | export(scale_colour_flatui) 63 | export(scale_colour_frontiers) 64 | export(scale_colour_futurama) 65 | export(scale_colour_gsea) 66 | export(scale_colour_igv) 67 | export(scale_colour_jama) 68 | export(scale_colour_jco) 69 | export(scale_colour_lancet) 70 | export(scale_colour_locuszoom) 71 | export(scale_colour_material) 72 | export(scale_colour_nejm) 73 | export(scale_colour_npg) 74 | export(scale_colour_observable) 75 | export(scale_colour_rickandmorty) 76 | export(scale_colour_simpsons) 77 | export(scale_colour_startrek) 78 | export(scale_colour_tron) 79 | export(scale_colour_tw3) 80 | export(scale_colour_uchicago) 81 | export(scale_colour_ucscgb) 82 | export(scale_fill_aaas) 83 | export(scale_fill_bmj) 84 | export(scale_fill_bs5) 85 | export(scale_fill_cosmic) 86 | export(scale_fill_d3) 87 | export(scale_fill_flatui) 88 | export(scale_fill_frontiers) 89 | export(scale_fill_futurama) 90 | export(scale_fill_gsea) 91 | export(scale_fill_igv) 92 | export(scale_fill_jama) 93 | export(scale_fill_jco) 94 | export(scale_fill_lancet) 95 | export(scale_fill_locuszoom) 96 | export(scale_fill_material) 97 | export(scale_fill_nejm) 98 | export(scale_fill_npg) 99 | export(scale_fill_observable) 100 | export(scale_fill_rickandmorty) 101 | export(scale_fill_simpsons) 102 | export(scale_fill_startrek) 103 | export(scale_fill_tron) 104 | export(scale_fill_tw3) 105 | export(scale_fill_uchicago) 106 | export(scale_fill_ucscgb) 107 | importFrom(ggplot2,discrete_scale) 108 | importFrom(ggplot2,scale_color_gradientn) 109 | importFrom(ggplot2,scale_fill_gradientn) 110 | importFrom(grDevices,col2rgb) 111 | importFrom(grDevices,colorRamp) 112 | importFrom(grDevices,rgb) 113 | importFrom(scales,manual_pal) 114 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # ggsci 3.2.0 2 | 3 | ## New features 4 | 5 | - Add the Observable 10 palette in `scale_color_observable()` 6 | and `scale_fill_observable()` (#41). 7 | - Add Bootstrap 5 color palettes (continuous) in `scale_color_bs5()` 8 | and `scale_fill_bs5()` (#18). 9 | - Add Tailwind CSS color palettes (continuous) in `scale_color_tw3()` 10 | and `scale_fill_tw3()` (#19). 11 | 12 | ## Improvements 13 | 14 | - Move internal color palette data from `R/sysdata.rda` to `R/palettes.R`. 15 | This change enhances package development transparency, reduces unnecessary 16 | indirection, and simplifies contributions by avoiding the construction 17 | of the palette data using the R script in `data-raw/` (#42). 18 | - For continuous palette examples, remove the reshape2 dependency and 19 | use more compact grid layout to reduce output image size (#45). 20 | 21 | # ggsci 3.1.0 22 | 23 | ## New features 24 | 25 | - The BMJ color palettes are implemented in `scale_color_bmj()` 26 | and `scale_fill_bmj()` (thanks, @huichen99, #32). 27 | 28 | ## Documentation 29 | 30 | - Convert Rd syntax to Markdown in roxygen2 documentation. 31 | This simplifies documentation formatting and makes it much easier 32 | to add new color scales for contributors (#35). 33 | 34 | # ggsci 3.0.3 35 | 36 | ## Improvements 37 | 38 | - Detect ggplot2 version at runtime to determine if the argument `scale_name` 39 | is needed for all `discrete_scale()` calls. This ensures ggsci always works 40 | regardless of the ggplot2 version installed (thanks, @flyingicedragon, #29). 41 | 42 | # ggsci 3.0.2 43 | 44 | ## Improvements 45 | 46 | - Remove `scale_name` from all `discrete_scale()` calls because the 47 | argument has been deprecated in ggplot2 3.5.0 (thanks, @DanChaltiel, #25). 48 | 49 | # ggsci 3.0.1 50 | 51 | ## Improvements 52 | 53 | - Expand the FAQ vignette to include a solution for 54 | [customizing color selection and ordering in a palette](https://nanx.me/ggsci/articles/ggsci-faq.html#customize-color-ordering-in-a-palette) 55 | with self-defined color scale functions (#23). 56 | - Fix "lost braces" check notes on r-devel by using Unicode characters 57 | ([a91faf1](https://github.com/nanxstats/ggsci/commit/a91faf183ae44fe43355283c173a1e2de70de6d2)). 58 | 59 | # ggsci 3.0.0 60 | 61 | ## New features 62 | 63 | - Added three Flat UI color palettes in 64 | - `scale_color_flatui()` 65 | - `scale_fill_flatui()` 66 | 67 | and one color palette inspired by the logo of frontiers.org in 68 | - `scale_color_frontiers()` 69 | - `scale_fill_frontiers()` 70 | (thanks, @clarajegousse, #14). 71 | - Added three COSMIC color palettes in 72 | - `scale_color_cosmic()` 73 | - `scale_fill_cosmic()` 74 | 75 | (thanks, @jhrcook, #5, #7). 76 | 77 | ## Improvements 78 | 79 | - Use a proper, three-component version number following Semantic Versioning. 80 | - Reduce output figure size in vignettes and `README.Rmd` by switching to the 81 | ragg PNG device and using pngquant for compression. 82 | - Added a new vignette on frequently asked questions. 83 | - A simple solution to interpolate the color palettes when the data has more 84 | categories than the number of colors in a discrete color scale. 85 | - A note on using a color scale consistently for multiple ggplot2 plots by 86 | setting global options (thanks, @DanChaltiel, #13). 87 | - Replace `size` with `linewidth` in code examples for ggplot2 >= 3.4.0. 88 | - Replaced the previous logo with a new hex sticker logo. 89 | - Replaced previous CI/CD solutions with GitHub Actions workflows. 90 | - Fixed broken or moved links in function documentation and vignettes. 91 | - Removed the `LazyData` field from `DESCRIPTION`. 92 | 93 | # ggsci 2.9 94 | 95 | ## Improvements 96 | 97 | - New URL for the documentation website: . 98 | 99 | # ggsci 2.8 100 | 101 | ## Improvements 102 | 103 | - Use system font stack instead of Google Fonts in vignettes to avoid pandoc SSL issue. 104 | 105 | # ggsci 2.7 106 | 107 | ## New features 108 | 109 | Two new discrete color palettes: 110 | 111 | - JAMA 112 | - Tron Legacy 113 | 114 | One new collection of continuous palettes with 19 color options: 115 | 116 | - Material Design 117 | 118 | # ggsci 2.4 119 | 120 | ## New features 121 | 122 | Four new discrete color palettes: 123 | 124 | - NEJM 125 | - LocusZoom 126 | - IGV 127 | - Star Trek 128 | 129 | # ggsci 2.0 130 | 131 | ## New features 132 | 133 | Two new discrete color palettes: 134 | 135 | - D3.js (v3) 136 | - Futurama (Planet Express) 137 | 138 | The first continuous color palette: 139 | 140 | - GSEA GenePattern 141 | 142 | # ggsci 1.0 143 | 144 | ## New features 145 | 146 | Eight discrete color palettes (2016-04-01): 147 | 148 | - NPG 149 | - AAAS 150 | - Lancet 151 | - JCO 152 | - UCSCGB 153 | - UChicago 154 | - The Simpsons (Springfield) 155 | - Rick and Morty (Schwifty) 156 | -------------------------------------------------------------------------------- /R/continuous-bs5.R: -------------------------------------------------------------------------------- 1 | #' Bootstrap 5 color palettes 2 | #' 3 | #' Bootstrap 5 color palettes. 4 | #' 5 | #' @param palette Palette type. There are 11 available options: 6 | #' - `"blue"` 7 | #' - `"indigo"` 8 | #' - `"purple"` 9 | #' - `"pink"` 10 | #' - `"red"` 11 | #' - `"orange"` 12 | #' - `"yellow"` 13 | #' - `"green"` 14 | #' - `"teal"` 15 | #' - `"cyan"` 16 | #' - `"gray"` 17 | #' @param n Number of individual colors to be generated. 18 | #' @param alpha Transparency level, a real number in (0, 1]. 19 | #' See `alpha` in [grDevices::rgb()] for details. 20 | #' @param reverse Logical. Should the order of the colors be reversed? 21 | #' 22 | #' @export rgb_bs5 23 | #' 24 | #' @importFrom grDevices colorRamp rgb 25 | #' @importFrom scales manual_pal 26 | #' 27 | #' @author Nan Xiao | \email{me@nanx.me} | 28 | #' 29 | #' @references 30 | #' 31 | #' 32 | #' @examples 33 | #' library("scales") 34 | #' show_col(pal_bs5("indigo")(10)) 35 | #' show_col(pal_bs5("indigo", n = 30, alpha = 0.6, reverse = TRUE)(30)) 36 | rgb_bs5 <- function( 37 | palette = c( 38 | "blue", "indigo", "purple", "pink", "red", "orange", "yellow", 39 | "green", "teal", "cyan", "gray" 40 | ), n = 10, alpha = 1, reverse = FALSE) { 41 | palette <- match.arg(palette) 42 | 43 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 44 | 45 | raw_cols <- ggsci_db$"bs5"[[palette]] 46 | func_cols <- colorRamp(raw_cols, space = "Lab", interpolate = "spline") 47 | mat_cols <- func_cols(seq(0L, 1L, length.out = n)) 48 | alpha_cols <- rgb( 49 | mat_cols[, 1L], mat_cols[, 2L], mat_cols[, 3L], 50 | alpha = alpha * 255L, maxColorValue = 255L 51 | ) 52 | 53 | if (reverse) alpha_cols <- rev(alpha_cols) 54 | 55 | alpha_cols 56 | } 57 | 58 | #' Bootstrap 5 color palettes 59 | #' 60 | #' Bootstrap 5 color palettes. 61 | #' 62 | #' @inheritParams rgb_bs5 63 | #' 64 | #' @export pal_bs5 65 | #' 66 | #' @importFrom scales manual_pal 67 | #' 68 | #' @author Nan Xiao | \email{me@nanx.me} | 69 | #' 70 | #' @examples 71 | #' library("scales") 72 | #' show_col(pal_bs5("indigo")(10)) 73 | #' show_col(pal_bs5("indigo", n = 30, alpha = 0.6, reverse = TRUE)(30)) 74 | pal_bs5 <- function( 75 | palette = c( 76 | "blue", "indigo", "purple", "pink", "red", "orange", "yellow", 77 | "green", "teal", "cyan", "gray" 78 | ), n = 10, alpha = 1, reverse = FALSE) { 79 | palette <- match.arg(palette) 80 | 81 | alpha_cols <- rgb_bs5(palette, n, alpha, reverse) 82 | manual_pal(unname(alpha_cols)) 83 | } 84 | 85 | #' Bootstrap 5 color scales 86 | #' 87 | #' See [pal_bs5()] for details. 88 | #' 89 | #' @inheritParams pal_bs5 90 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 91 | #' 92 | #' @export scale_color_bs5 93 | #' 94 | #' @importFrom ggplot2 scale_color_gradientn 95 | #' 96 | #' @author Nan Xiao | \email{me@nanx.me} | 97 | #' 98 | #' @rdname scale_bs5 99 | #' 100 | #' @examples 101 | #' library("ggplot2") 102 | #' 103 | #' data("mtcars") 104 | #' cor <- abs(cor(mtcars)) 105 | #' cor_melt <- data.frame( 106 | #' Var1 = rep(seq_len(nrow(cor)), times = ncol(cor)), 107 | #' Var2 = rep(seq_len(ncol(cor)), each = nrow(cor)), 108 | #' value = as.vector(cor) 109 | #' ) 110 | #' 111 | #' ggplot( 112 | #' cor_melt, 113 | #' aes(x = Var1, y = Var2, fill = value) 114 | #' ) + 115 | #' geom_tile(colour = "black", size = 0.3) + 116 | #' theme_bw() + 117 | #' scale_fill_bs5("teal") 118 | scale_color_bs5 <- function( 119 | palette = c( 120 | "blue", "indigo", "purple", "pink", "red", "orange", "yellow", 121 | "green", "teal", "cyan", "gray" 122 | ), alpha = 1, reverse = FALSE, ...) { 123 | palette <- match.arg(palette) 124 | scale_color_gradientn( 125 | colours = rgb_bs5( 126 | palette, 127 | n = 512, alpha = alpha, reverse = reverse 128 | ), 129 | ... 130 | ) 131 | } 132 | 133 | #' @export scale_colour_bs5 134 | #' @rdname scale_bs5 135 | scale_colour_bs5 <- scale_color_bs5 136 | 137 | #' @export scale_fill_bs5 138 | #' @importFrom ggplot2 scale_fill_gradientn 139 | #' @rdname scale_bs5 140 | scale_fill_bs5 <- function( 141 | palette = c( 142 | "blue", "indigo", "purple", "pink", "red", "orange", "yellow", 143 | "green", "teal", "cyan", "gray" 144 | ), alpha = 1, reverse = FALSE, ...) { 145 | palette <- match.arg(palette) 146 | scale_fill_gradientn( 147 | colours = rgb_bs5( 148 | palette, 149 | n = 512, alpha = alpha, reverse = reverse 150 | ), 151 | ... 152 | ) 153 | } 154 | -------------------------------------------------------------------------------- /R/continuous-gsea.R: -------------------------------------------------------------------------------- 1 | #' The GSEA GenePattern color palettes 2 | #' 3 | #' Color palette inspired by the colors used in the 4 | #' heatmaps plotted by GSEA GenePattern. 5 | #' 6 | #' @param palette Palette type. 7 | #' Currently there is one available option: `"default"` 8 | #' (continuous palette with 12 base colors). 9 | #' @param n Number of individual colors to be generated. 10 | #' @param alpha Transparency level, a real number in (0, 1]. 11 | #' See `alpha` in [grDevices::rgb()] for details. 12 | #' @param reverse Logical. Should the order of the colors be reversed? 13 | #' 14 | #' @export rgb_gsea 15 | #' 16 | #' @importFrom grDevices colorRamp rgb 17 | #' @importFrom scales manual_pal 18 | #' 19 | #' @author Nan Xiao | \email{me@nanx.me} | 20 | #' 21 | #' @note The 12 base colors used in this palette are derived from the 22 | #' [HeatMapImage documentation](https://modulerepository.genepattern.org/gpModuleRepository/download/prod/module/?file=/HeatMapImage/broad.mit.edu:cancer.software.genepattern.module.analysis/00032/6/HeatMapImage.pdf). 23 | #' 24 | #' @examples 25 | #' library("scales") 26 | #' show_col(pal_gsea("default")(12)) 27 | #' show_col(pal_gsea("default", n = 30, alpha = 0.6, reverse = TRUE)(30)) 28 | rgb_gsea <- function(palette = c("default"), n = 12, alpha = 1, reverse = FALSE) { 29 | palette <- match.arg(palette) 30 | 31 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 32 | 33 | raw_cols <- ggsci_db$"gsea"[[palette]] 34 | func_cols <- colorRamp(raw_cols, space = "Lab", interpolate = "spline") 35 | mat_cols <- func_cols(seq(0L, 1L, length.out = n)) 36 | alpha_cols <- rgb( 37 | mat_cols[, 1L], mat_cols[, 2L], mat_cols[, 3L], 38 | alpha = alpha * 255L, maxColorValue = 255L 39 | ) 40 | 41 | if (reverse) alpha_cols <- rev(alpha_cols) 42 | 43 | alpha_cols 44 | } 45 | 46 | #' The GSEA GenePattern color palettes 47 | #' 48 | #' Color palette inspired by the colors used in the 49 | #' heatmaps plotted by GSEA GenePattern. 50 | #' 51 | #' @inheritParams rgb_gsea 52 | #' 53 | #' @export pal_gsea 54 | #' 55 | #' @importFrom scales manual_pal 56 | #' 57 | #' @author Nan Xiao | \email{me@nanx.me} | 58 | #' 59 | #' @examples 60 | #' library("scales") 61 | #' show_col(pal_gsea("default")(12)) 62 | #' show_col(pal_gsea("default", n = 30, alpha = 0.6, reverse = TRUE)(30)) 63 | pal_gsea <- function(palette = c("default"), n = 12, alpha = 1, reverse = FALSE) { 64 | palette <- match.arg(palette) 65 | alpha_cols <- rgb_gsea(palette, n, alpha, reverse) 66 | manual_pal(unname(alpha_cols)) 67 | } 68 | 69 | #' The GSEA GenePattern color scales 70 | #' 71 | #' See [pal_gsea()] for details. 72 | #' 73 | #' @inheritParams pal_gsea 74 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 75 | #' 76 | #' @export scale_color_gsea 77 | #' 78 | #' @importFrom ggplot2 scale_color_gradientn 79 | #' 80 | #' @author Nan Xiao | \email{me@nanx.me} | 81 | #' 82 | #' @rdname scale_gsea 83 | #' 84 | #' @examples 85 | #' library("ggplot2") 86 | #' 87 | #' data("mtcars") 88 | #' cor <- cor(mtcars) 89 | #' cor_melt <- data.frame( 90 | #' Var1 = rep(seq_len(nrow(cor)), times = ncol(cor)), 91 | #' Var2 = rep(seq_len(ncol(cor)), each = nrow(cor)), 92 | #' value = as.vector(cor) 93 | #' ) 94 | #' 95 | #' ggplot( 96 | #' cor_melt, 97 | #' aes(x = Var1, y = Var2, fill = value) 98 | #' ) + 99 | #' geom_tile(colour = "black", size = 0.3) + 100 | #' theme_bw() + 101 | #' scale_fill_gsea() 102 | scale_color_gsea <- function(palette = c("default"), alpha = 1, reverse = FALSE, ...) { 103 | palette <- match.arg(palette) 104 | scale_color_gradientn(colours = rgb_gsea(palette, n = 512, alpha = alpha, reverse = reverse), ...) 105 | } 106 | 107 | #' @export scale_colour_gsea 108 | #' @rdname scale_gsea 109 | scale_colour_gsea <- scale_color_gsea 110 | 111 | #' @export scale_fill_gsea 112 | #' @importFrom ggplot2 scale_fill_gradientn 113 | #' @rdname scale_gsea 114 | scale_fill_gsea <- function(palette = c("default"), alpha = 1, reverse = FALSE, ...) { 115 | palette <- match.arg(palette) 116 | scale_fill_gradientn(colours = rgb_gsea(palette, n = 512, alpha = alpha, reverse = reverse), ...) 117 | } 118 | -------------------------------------------------------------------------------- /R/continuous-material.R: -------------------------------------------------------------------------------- 1 | #' Material Design color palettes 2 | #' 3 | #' Material Design 2 color palettes. 4 | #' 5 | #' @param palette Palette type. There are 19 available options: 6 | #' - `"red"` 7 | #' - `"pink"` 8 | #' - `"purple"` 9 | #' - `"deep-purple"` 10 | #' - `"indigo"` 11 | #' - `"blue"` 12 | #' - `"light-blue"` 13 | #' - `"cyan"` 14 | #' - `"teal"` 15 | #' - `"green"` 16 | #' - `"light-green"` 17 | #' - `"lime"` 18 | #' - `"yellow"` 19 | #' - `"amber"` 20 | #' - `"orange"` 21 | #' - `"deep-orange"` 22 | #' - `"brown"` 23 | #' - `"grey"` 24 | #' - `"blue-grey"` 25 | #' @param n Number of individual colors to be generated. 26 | #' @param alpha Transparency level, a real number in (0, 1]. 27 | #' See `alpha` in [grDevices::rgb()] for details. 28 | #' @param reverse Logical. Should the order of the colors be reversed? 29 | #' 30 | #' @export rgb_material 31 | #' 32 | #' @importFrom grDevices colorRamp rgb 33 | #' @importFrom scales manual_pal 34 | #' 35 | #' @author Nan Xiao | \email{me@nanx.me} | 36 | #' 37 | #' @references 38 | #' 39 | #' 40 | #' @examples 41 | #' library("scales") 42 | #' show_col(pal_material("indigo")(10)) 43 | #' show_col(pal_material("indigo", n = 30, alpha = 0.6, reverse = TRUE)(30)) 44 | rgb_material <- function( 45 | palette = c( 46 | "red", "pink", "purple", "deep-purple", "indigo", "blue", 47 | "light-blue", "cyan", "teal", "green", "light-green", "lime", 48 | "yellow", "amber", "orange", "deep-orange", "brown", "grey", "blue-grey" 49 | ), n = 10, alpha = 1, reverse = FALSE) { 50 | palette <- match.arg(palette) 51 | 52 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 53 | 54 | raw_cols <- ggsci_db$"material"[[palette]] 55 | func_cols <- colorRamp(raw_cols, space = "Lab", interpolate = "spline") 56 | mat_cols <- func_cols(seq(0L, 1L, length.out = n)) 57 | alpha_cols <- rgb( 58 | mat_cols[, 1L], mat_cols[, 2L], mat_cols[, 3L], 59 | alpha = alpha * 255L, maxColorValue = 255L 60 | ) 61 | 62 | if (reverse) alpha_cols <- rev(alpha_cols) 63 | 64 | alpha_cols 65 | } 66 | 67 | #' Material Design color palettes 68 | #' 69 | #' Material Design 2 color palettes. 70 | #' 71 | #' @inheritParams rgb_material 72 | #' 73 | #' @export pal_material 74 | #' 75 | #' @importFrom scales manual_pal 76 | #' 77 | #' @author Nan Xiao | \email{me@nanx.me} | 78 | #' 79 | #' @examples 80 | #' library("scales") 81 | #' show_col(pal_material("indigo")(10)) 82 | #' show_col(pal_material("indigo", n = 30, alpha = 0.6, reverse = TRUE)(30)) 83 | pal_material <- function( 84 | palette = c( 85 | "red", "pink", "purple", "deep-purple", "indigo", "blue", 86 | "light-blue", "cyan", "teal", "green", "light-green", "lime", 87 | "yellow", "amber", "orange", "deep-orange", "brown", "grey", "blue-grey" 88 | ), n = 10, alpha = 1, reverse = FALSE) { 89 | palette <- match.arg(palette) 90 | 91 | alpha_cols <- rgb_material(palette, n, alpha, reverse) 92 | manual_pal(unname(alpha_cols)) 93 | } 94 | 95 | #' Material Design color scales 96 | #' 97 | #' See [pal_material()] for details. 98 | #' 99 | #' @inheritParams pal_material 100 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 101 | #' 102 | #' @export scale_color_material 103 | #' 104 | #' @importFrom ggplot2 scale_color_gradientn 105 | #' 106 | #' @author Nan Xiao | \email{me@nanx.me} | 107 | #' 108 | #' @rdname scale_material 109 | #' 110 | #' @examples 111 | #' library("ggplot2") 112 | #' 113 | #' data("mtcars") 114 | #' cor <- abs(cor(mtcars)) 115 | #' cor_melt <- data.frame( 116 | #' Var1 = rep(seq_len(nrow(cor)), times = ncol(cor)), 117 | #' Var2 = rep(seq_len(ncol(cor)), each = nrow(cor)), 118 | #' value = as.vector(cor) 119 | #' ) 120 | #' 121 | #' ggplot( 122 | #' cor_melt, 123 | #' aes(x = Var1, y = Var2, fill = value) 124 | #' ) + 125 | #' geom_tile(colour = "black", size = 0.3) + 126 | #' theme_bw() + 127 | #' scale_fill_material("blue-grey") 128 | scale_color_material <- function( 129 | palette = c( 130 | "red", "pink", "purple", "deep-purple", "indigo", "blue", 131 | "light-blue", "cyan", "teal", "green", "light-green", "lime", 132 | "yellow", "amber", "orange", "deep-orange", "brown", "grey", "blue-grey" 133 | ), alpha = 1, reverse = FALSE, ...) { 134 | palette <- match.arg(palette) 135 | scale_color_gradientn( 136 | colours = rgb_material( 137 | palette, 138 | n = 512, alpha = alpha, reverse = reverse 139 | ), 140 | ... 141 | ) 142 | } 143 | 144 | #' @export scale_colour_material 145 | #' @rdname scale_material 146 | scale_colour_material <- scale_color_material 147 | 148 | #' @export scale_fill_material 149 | #' @importFrom ggplot2 scale_fill_gradientn 150 | #' @rdname scale_material 151 | scale_fill_material <- function( 152 | palette = c( 153 | "red", "pink", "purple", "deep-purple", "indigo", "blue", 154 | "light-blue", "cyan", "teal", "green", "light-green", "lime", 155 | "yellow", "amber", "orange", "deep-orange", "brown", "grey", "blue-grey" 156 | ), alpha = 1, reverse = FALSE, ...) { 157 | palette <- match.arg(palette) 158 | scale_fill_gradientn( 159 | colours = rgb_material( 160 | palette, 161 | n = 512, alpha = alpha, reverse = reverse 162 | ), 163 | ... 164 | ) 165 | } 166 | -------------------------------------------------------------------------------- /R/continuous-tw3.R: -------------------------------------------------------------------------------- 1 | #' Tailwind CSS color palettes 2 | #' 3 | #' Tailwind CSS color palettes. 4 | #' 5 | #' @param palette Palette type. There are 22 available options: 6 | #' - `"slate"` 7 | #' - `"gray"` 8 | #' - `"zinc"` 9 | #' - `"neutral"` 10 | #' - `"stone"` 11 | #' - `"red"` 12 | #' - `"orange"` 13 | #' - `"amber"` 14 | #' - `"yellow"` 15 | #' - `"lime"` 16 | #' - `"green"` 17 | #' - `"emerald"` 18 | #' - `"teal"` 19 | #' - `"cyan"` 20 | #' - `"sky"` 21 | #' - `"blue"` 22 | #' - `"indigo"` 23 | #' - `"violet"` 24 | #' - `"purple"` 25 | #' - `"fuchsia"` 26 | #' - `"pink"` 27 | #' - `"rose"` 28 | #' @param n Number of individual colors to be generated. 29 | #' @param alpha Transparency level, a real number in (0, 1]. 30 | #' See `alpha` in [grDevices::rgb()] for details. 31 | #' @param reverse Logical. Should the order of the colors be reversed? 32 | #' 33 | #' @export rgb_tw3 34 | #' 35 | #' @importFrom grDevices colorRamp rgb 36 | #' @importFrom scales manual_pal 37 | #' 38 | #' @author Nan Xiao | \email{me@nanx.me} | 39 | #' 40 | #' @references 41 | #' 42 | #' 43 | #' @examples 44 | #' library("scales") 45 | #' show_col(pal_tw3("rose")(10)) 46 | #' show_col(pal_tw3("rose", n = 30, alpha = 0.6, reverse = TRUE)(30)) 47 | rgb_tw3 <- function( 48 | palette = c( 49 | "slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 50 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", 51 | "indigo", "violet", "purple", "fuchsia", "pink", "rose" 52 | ), n = 10, alpha = 1, reverse = FALSE) { 53 | palette <- match.arg(palette) 54 | 55 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 56 | 57 | raw_cols <- ggsci_db$"tw3"[[palette]] 58 | func_cols <- colorRamp(raw_cols, space = "Lab", interpolate = "spline") 59 | mat_cols <- func_cols(seq(0L, 1L, length.out = n)) 60 | alpha_cols <- rgb( 61 | mat_cols[, 1L], mat_cols[, 2L], mat_cols[, 3L], 62 | alpha = alpha * 255L, maxColorValue = 255L 63 | ) 64 | 65 | if (reverse) alpha_cols <- rev(alpha_cols) 66 | 67 | alpha_cols 68 | } 69 | 70 | #' Tailwind CSS color palettes 71 | #' 72 | #' Tailwind CSS color palettes. 73 | #' 74 | #' @inheritParams rgb_tw3 75 | #' 76 | #' @export pal_tw3 77 | #' 78 | #' @importFrom scales manual_pal 79 | #' 80 | #' @author Nan Xiao | \email{me@nanx.me} | 81 | #' 82 | #' @examples 83 | #' library("scales") 84 | #' show_col(pal_tw3("rose")(10)) 85 | #' show_col(pal_tw3("rose", n = 30, alpha = 0.6, reverse = TRUE)(30)) 86 | pal_tw3 <- function( 87 | palette = c( 88 | "slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 89 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", 90 | "indigo", "violet", "purple", "fuchsia", "pink", "rose" 91 | ), n = 10, alpha = 1, reverse = FALSE) { 92 | palette <- match.arg(palette) 93 | 94 | alpha_cols <- rgb_tw3(palette, n, alpha, reverse) 95 | manual_pal(unname(alpha_cols)) 96 | } 97 | 98 | #' Tailwind CSS color scales 99 | #' 100 | #' See [pal_tw3()] for details. 101 | #' 102 | #' @inheritParams pal_tw3 103 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 104 | #' 105 | #' @export scale_color_tw3 106 | #' 107 | #' @importFrom ggplot2 scale_color_gradientn 108 | #' 109 | #' @author Nan Xiao | \email{me@nanx.me} | 110 | #' 111 | #' @rdname scale_tw3 112 | #' 113 | #' @examples 114 | #' library("ggplot2") 115 | #' 116 | #' data("mtcars") 117 | #' cor <- abs(cor(mtcars)) 118 | #' cor_melt <- data.frame( 119 | #' Var1 = rep(seq_len(nrow(cor)), times = ncol(cor)), 120 | #' Var2 = rep(seq_len(ncol(cor)), each = nrow(cor)), 121 | #' value = as.vector(cor) 122 | #' ) 123 | #' 124 | #' ggplot( 125 | #' cor_melt, 126 | #' aes(x = Var1, y = Var2, fill = value) 127 | #' ) + 128 | #' geom_tile(colour = "black", size = 0.3) + 129 | #' theme_bw() + 130 | #' scale_fill_tw3("slate") 131 | scale_color_tw3 <- function( 132 | palette = c( 133 | "slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 134 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", 135 | "indigo", "violet", "purple", "fuchsia", "pink", "rose" 136 | ), alpha = 1, reverse = FALSE, ...) { 137 | palette <- match.arg(palette) 138 | scale_color_gradientn( 139 | colours = rgb_tw3( 140 | palette, 141 | n = 512, alpha = alpha, reverse = reverse 142 | ), 143 | ... 144 | ) 145 | } 146 | 147 | #' @export scale_colour_tw3 148 | #' @rdname scale_tw3 149 | scale_colour_tw3 <- scale_color_tw3 150 | 151 | #' @export scale_fill_tw3 152 | #' @importFrom ggplot2 scale_fill_gradientn 153 | #' @rdname scale_tw3 154 | scale_fill_tw3 <- function( 155 | palette = c( 156 | "slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 157 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", 158 | "indigo", "violet", "purple", "fuchsia", "pink", "rose" 159 | ), alpha = 1, reverse = FALSE, ...) { 160 | palette <- match.arg(palette) 161 | scale_fill_gradientn( 162 | colours = rgb_tw3( 163 | palette, 164 | n = 512, alpha = alpha, reverse = reverse 165 | ), 166 | ... 167 | ) 168 | } 169 | -------------------------------------------------------------------------------- /R/discrete-aaas.R: -------------------------------------------------------------------------------- 1 | #' AAAS journal color palettes 2 | #' 3 | #' Color palettes inspired by plots in journals published by 4 | #' American Association for the Advancement of Science (AAAS), 5 | #' such as _Science_ and _Science Translational Medicine_. 6 | #' 7 | #' @param palette Palette type. 8 | #' Currently there is one available option: `"default"` 9 | #' (10-color palette inspired by _Science_). 10 | #' @param alpha Transparency level, a real number in (0, 1]. 11 | #' See `alpha` in [grDevices::rgb()] for details. 12 | #' 13 | #' @export pal_aaas 14 | #' 15 | #' @importFrom grDevices col2rgb rgb 16 | #' @importFrom scales manual_pal 17 | #' 18 | #' @author Nan Xiao | \email{me@nanx.me} | 19 | #' 20 | #' @examples 21 | #' library("scales") 22 | #' show_col(pal_aaas("default")(10)) 23 | #' show_col(pal_aaas("default", alpha = 0.6)(10)) 24 | pal_aaas <- function(palette = c("default"), alpha = 1) { 25 | palette <- match.arg(palette) 26 | 27 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 28 | 29 | raw_cols <- ggsci_db$"aaas"[[palette]] 30 | raw_cols_rgb <- col2rgb(raw_cols) 31 | alpha_cols <- rgb( 32 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 33 | alpha = alpha * 255L, names = names(raw_cols), 34 | maxColorValue = 255L 35 | ) 36 | 37 | manual_pal(unname(alpha_cols)) 38 | } 39 | 40 | #' AAAS journal color scales 41 | #' 42 | #' See [pal_aaas()] for details. 43 | #' 44 | #' @inheritParams pal_aaas 45 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 46 | #' 47 | #' @export scale_color_aaas 48 | #' 49 | #' @importFrom ggplot2 discrete_scale 50 | #' 51 | #' @author Nan Xiao | \email{me@nanx.me} | 52 | #' 53 | #' @rdname scale_aaas 54 | #' 55 | #' @examples 56 | #' library("ggplot2") 57 | #' data("diamonds") 58 | #' 59 | #' ggplot( 60 | #' subset(diamonds, carat >= 2.2), 61 | #' aes(x = table, y = price, colour = cut) 62 | #' ) + 63 | #' geom_point(alpha = 0.7) + 64 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 65 | #' theme_bw() + 66 | #' scale_color_aaas() 67 | #' 68 | #' ggplot( 69 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 70 | #' aes(x = depth, fill = cut) 71 | #' ) + 72 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 73 | #' theme_bw() + 74 | #' scale_fill_aaas() 75 | scale_color_aaas <- function(palette = c("default"), alpha = 1, ...) { 76 | palette <- match.arg(palette) 77 | if (is_ggplot2_350()) { 78 | discrete_scale("colour", palette = pal_aaas(palette, alpha), ...) 79 | } else { 80 | discrete_scale("colour", scale_name = "aaas", palette = pal_aaas(palette, alpha), ...) 81 | } 82 | } 83 | 84 | #' @export scale_colour_aaas 85 | #' @rdname scale_aaas 86 | scale_colour_aaas <- scale_color_aaas 87 | 88 | #' @export scale_fill_aaas 89 | #' @importFrom ggplot2 discrete_scale 90 | #' @rdname scale_aaas 91 | scale_fill_aaas <- function(palette = c("default"), alpha = 1, ...) { 92 | palette <- match.arg(palette) 93 | if (is_ggplot2_350()) { 94 | discrete_scale("fill", palette = pal_aaas(palette, alpha), ...) 95 | } else { 96 | discrete_scale("fill", scale_name = "aaas", palette = pal_aaas(palette, alpha), ...) 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /R/discrete-bmj.R: -------------------------------------------------------------------------------- 1 | #' BMJ color palettes 2 | #' 3 | #' Color palette from the BMJ living style guide. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"default"` 7 | #' (9-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_bmj 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Hui Chen | \email{huichen@zju.edu.cn} 17 | #' 18 | #' @references 19 | #' 20 | #' 21 | #' @examples 22 | #' library("scales") 23 | #' show_col(pal_bmj("default")(9)) 24 | #' show_col(pal_bmj("default", alpha = 0.6)(9)) 25 | pal_bmj <- function(palette = c("default"), alpha = 1) { 26 | palette <- match.arg(palette) 27 | 28 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 29 | 30 | raw_cols <- ggsci_db$"bmj"[[palette]] 31 | raw_cols_rgb <- col2rgb(raw_cols) 32 | alpha_cols <- rgb( 33 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 34 | alpha = alpha * 255L, names = names(raw_cols), 35 | maxColorValue = 255L 36 | ) 37 | 38 | manual_pal(unname(alpha_cols)) 39 | } 40 | 41 | #' BMJ color scales 42 | #' 43 | #' See [pal_bmj()] for details. 44 | #' 45 | #' @inheritParams pal_bmj 46 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 47 | #' 48 | #' @export scale_color_bmj 49 | #' 50 | #' @importFrom ggplot2 discrete_scale 51 | #' 52 | #' @author Hui Chen | \email{huichen@zju.edu.cn} 53 | #' 54 | #' @rdname scale_bmj 55 | #' 56 | #' @references 57 | #' 58 | #' 59 | #' @examples 60 | #' library("ggplot2") 61 | #' data("diamonds") 62 | #' 63 | #' ggplot( 64 | #' subset(diamonds, carat >= 2.2), 65 | #' aes(x = table, y = price, colour = cut) 66 | #' ) + 67 | #' geom_point(alpha = 0.7) + 68 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 69 | #' theme_bw() + 70 | #' scale_color_bmj() 71 | #' 72 | #' ggplot( 73 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 74 | #' aes(x = depth, fill = cut) 75 | #' ) + 76 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 77 | #' theme_bw() + 78 | #' scale_fill_bmj() 79 | scale_color_bmj <- function(palette = c("default"), alpha = 1, ...) { 80 | palette <- match.arg(palette) 81 | if (is_ggplot2_350()) { 82 | discrete_scale("colour", palette = pal_bmj(palette, alpha), ...) 83 | } else { 84 | discrete_scale("colour", scale_name = "bmj", palette = pal_bmj(palette, alpha), ...) 85 | } 86 | } 87 | 88 | #' @export scale_colour_bmj 89 | #' @rdname scale_bmj 90 | scale_colour_bmj <- scale_color_bmj 91 | 92 | #' @export scale_fill_bmj 93 | #' @importFrom ggplot2 discrete_scale 94 | #' @rdname scale_bmj 95 | scale_fill_bmj <- function(palette = c("default"), alpha = 1, ...) { 96 | palette <- match.arg(palette) 97 | if (is_ggplot2_350()) { 98 | discrete_scale("fill", palette = pal_bmj(palette, alpha), ...) 99 | } else { 100 | discrete_scale("fill", scale_name = "bmj", palette = pal_bmj(palette, alpha), ...) 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /R/discrete-cosmic.R: -------------------------------------------------------------------------------- 1 | #' COSMIC color palettes 2 | #' 3 | #' Color palettes inspired by the colors used in projects from the 4 | #' [Catalogue Of 5 | #' Somatic Mutations in Cancers (COSMIC)](https://cancer.sanger.ac.uk/cosmic). 6 | #' 7 | #' @param palette Palette type. Currently there are three available options: 8 | #' - `"signature_substitutions"` (6-color palette). 9 | #' - `"hallmarks_light"` (10-color palette). 10 | #' - `"hallmarks_dark"` (10-color palette). 11 | #' 12 | #' The `"hallmarks_light"` option is from 13 | #' [Hanahan and Weinberg (2011)](https://pubmed.ncbi.nlm.nih.gov/21376230/). 14 | #' @param alpha Transparency level, a real number in (0, 1]. 15 | #' See `alpha` in [grDevices::rgb()] for details. 16 | #' 17 | #' @export pal_cosmic 18 | #' 19 | #' @importFrom grDevices col2rgb rgb 20 | #' @importFrom scales manual_pal 21 | #' 22 | #' @author Joshua H. Cook | \email{joshuacook0023@gmail.com} | 23 | #' [@jhrcook](https://github.com/jhrcook) 24 | #' 25 | #' @examples 26 | #' library("scales") 27 | #' show_col(pal_cosmic("hallmarks_light")(10)) 28 | #' show_col(pal_cosmic("hallmarks_light", alpha = 0.6)(10)) 29 | #' show_col(pal_cosmic("hallmarks_dark")(10)) 30 | #' show_col(pal_cosmic("hallmarks_dark", alpha = 0.6)(10)) 31 | #' show_col(pal_cosmic("signature_substitutions")(6)) 32 | #' show_col(pal_cosmic("signature_substitutions", alpha = 0.6)(6)) 33 | pal_cosmic <- function( 34 | palette = c("hallmarks_light", "hallmarks_dark", "signature_substitutions"), 35 | alpha = 1) { 36 | palette <- match.arg(palette) 37 | 38 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 39 | 40 | raw_cols <- ggsci_db$"cosmic"[[palette]] 41 | raw_cols_rgb <- col2rgb(raw_cols) 42 | alpha_cols <- rgb( 43 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 44 | alpha = alpha * 255L, names = names(raw_cols), 45 | maxColorValue = 255L 46 | ) 47 | 48 | manual_pal(unname(alpha_cols)) 49 | } 50 | 51 | #' COSMIC color scales 52 | #' 53 | #' See [pal_cosmic()] for details. 54 | #' 55 | #' @inheritParams pal_cosmic 56 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 57 | #' 58 | #' @export scale_color_cosmic 59 | #' 60 | #' @importFrom ggplot2 discrete_scale 61 | #' 62 | #' @author Joshua H. Cook | \email{joshuacook0023@gmail.com} | 63 | #' [@jhrcook](https://github.com/jhrcook) 64 | #' 65 | #' @rdname scale_cosmic 66 | #' 67 | #' @examples 68 | #' library("ggplot2") 69 | #' data("diamonds") 70 | #' 71 | #' ggplot( 72 | #' subset(diamonds, carat >= 2.2), 73 | #' aes(x = table, y = price, colour = cut) 74 | #' ) + 75 | #' geom_point(alpha = 0.7) + 76 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 77 | #' theme_bw() + 78 | #' scale_color_cosmic() 79 | #' 80 | #' ggplot( 81 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 82 | #' aes(x = depth, fill = cut) 83 | #' ) + 84 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 85 | #' theme_bw() + 86 | #' scale_fill_cosmic() 87 | scale_color_cosmic <- function( 88 | palette = c("hallmarks_light", "hallmarks_dark", "signature_substitutions"), 89 | alpha = 1, ...) { 90 | palette <- match.arg(palette) 91 | if (is_ggplot2_350()) { 92 | discrete_scale("colour", palette = pal_cosmic(palette, alpha), ...) 93 | } else { 94 | discrete_scale("colour", scale_name = "cosmic", palette = pal_cosmic(palette, alpha), ...) 95 | } 96 | } 97 | 98 | #' @export scale_colour_cosmic 99 | #' @rdname scale_cosmic 100 | scale_colour_cosmic <- scale_color_cosmic 101 | 102 | #' @export scale_fill_cosmic 103 | #' @importFrom ggplot2 discrete_scale 104 | #' @rdname scale_cosmic 105 | scale_fill_cosmic <- function( 106 | palette = c("hallmarks_light", "hallmarks_dark", "signature_substitutions"), 107 | alpha = 1, ...) { 108 | palette <- match.arg(palette) 109 | if (is_ggplot2_350()) { 110 | discrete_scale("fill", palette = pal_cosmic(palette, alpha), ...) 111 | } else { 112 | discrete_scale("fill", scale_name = "cosmic", palette = pal_cosmic(palette, alpha), ...) 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /R/discrete-d3.R: -------------------------------------------------------------------------------- 1 | #' D3.js color palettes 2 | #' 3 | #' Color palettes based on the colors used by D3.js. 4 | #' 5 | #' @param palette Palette type. There are four available options: 6 | #' - `"category10"` (10-color palette). 7 | #' - `"category20"` (20-color palette). 8 | #' - `"category20b"` (20-color palette). 9 | #' - `"category20c"` (20-color palette). 10 | #' @param alpha Transparency level, a real number in (0, 1]. 11 | #' See `alpha` in [grDevices::rgb()] for details. 12 | #' 13 | #' @export pal_d3 14 | #' 15 | #' @importFrom grDevices col2rgb rgb 16 | #' @importFrom scales manual_pal 17 | #' 18 | #' @author Nan Xiao | \email{me@nanx.me} | 19 | #' 20 | #' @references 21 | #' 22 | #' 23 | #' @examples 24 | #' library("scales") 25 | #' show_col(pal_d3("category10")(10)) 26 | #' show_col(pal_d3("category20")(20)) 27 | #' show_col(pal_d3("category20b")(20)) 28 | #' show_col(pal_d3("category20c")(20)) 29 | pal_d3 <- function(palette = c("category10", "category20", "category20b", "category20c"), alpha = 1) { 30 | palette <- match.arg(palette) 31 | 32 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 33 | 34 | raw_cols <- ggsci_db$"d3"[[palette]] 35 | raw_cols_rgb <- col2rgb(raw_cols) 36 | alpha_cols <- rgb( 37 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 38 | alpha = alpha * 255L, names = names(raw_cols), 39 | maxColorValue = 255L 40 | ) 41 | 42 | manual_pal(unname(alpha_cols)) 43 | } 44 | 45 | #' D3.js color scales 46 | #' 47 | #' See [pal_d3()] for details. 48 | #' 49 | #' @inheritParams pal_d3 50 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 51 | #' 52 | #' @export scale_color_d3 53 | #' 54 | #' @importFrom ggplot2 discrete_scale 55 | #' 56 | #' @author Nan Xiao | \email{me@nanx.me} | 57 | #' 58 | #' @references 59 | #' 60 | #' 61 | #' @rdname scale_d3 62 | #' 63 | #' @examples 64 | #' library("ggplot2") 65 | #' data("diamonds") 66 | #' 67 | #' p1 <- ggplot( 68 | #' subset(diamonds, carat >= 2.2), 69 | #' aes(x = table, y = price, colour = cut) 70 | #' ) + 71 | #' geom_point(alpha = 0.7) + 72 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 73 | #' theme_bw() 74 | #' 75 | #' p2 <- ggplot( 76 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 77 | #' aes(x = depth, fill = cut) 78 | #' ) + 79 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 80 | #' theme_bw() 81 | #' 82 | #' p1 + scale_color_d3() 83 | #' p2 + scale_fill_d3() 84 | #' 85 | #' p1 + scale_color_d3(palette = "category20") 86 | #' p2 + scale_fill_d3(palette = "category20") 87 | #' 88 | #' p1 + scale_color_d3(palette = "category20b") 89 | #' p2 + scale_fill_d3(palette = "category20b") 90 | #' 91 | #' p1 + scale_color_d3(palette = "category20c") 92 | #' p2 + scale_fill_d3(palette = "category20c") 93 | scale_color_d3 <- function(palette = c("category10", "category20", "category20b", "category20c"), alpha = 1, ...) { 94 | palette <- match.arg(palette) 95 | if (is_ggplot2_350()) { 96 | discrete_scale("colour", palette = pal_d3(palette, alpha), ...) 97 | } else { 98 | discrete_scale("colour", scale_name = "d3", palette = pal_d3(palette, alpha), ...) 99 | } 100 | } 101 | 102 | #' @export scale_colour_d3 103 | #' @rdname scale_d3 104 | scale_colour_d3 <- scale_color_d3 105 | 106 | #' @export scale_fill_d3 107 | #' @importFrom ggplot2 discrete_scale 108 | #' @rdname scale_d3 109 | scale_fill_d3 <- function(palette = c("category10", "category20", "category20b", "category20c"), alpha = 1, ...) { 110 | palette <- match.arg(palette) 111 | if (is_ggplot2_350()) { 112 | discrete_scale("fill", palette = pal_d3(palette, alpha), ...) 113 | } else { 114 | discrete_scale("fill", scale_name = "d3", palette = pal_d3(palette, alpha), ...) 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /R/discrete-flatui.R: -------------------------------------------------------------------------------- 1 | #' Flat UI color palettes 2 | #' 3 | #' Color palettes inspired by the Flat UI colors. 4 | #' 5 | #' @param palette Palette type. Currently there are three available options: 6 | #' - `"default"` (10-color palette). 7 | #' - `"flattastic"` (12-color palette). 8 | #' - `"aussie"` (10-color palette). 9 | #' @param alpha Transparency level, a real number in (0, 1]. 10 | #' See `alpha` in [grDevices::rgb()] for details. 11 | #' 12 | #' @export pal_flatui 13 | #' 14 | #' @importFrom grDevices col2rgb rgb 15 | #' @importFrom scales manual_pal 16 | #' 17 | #' @author Clara Jégousse | \email{cat3@hi.is} 18 | #' 19 | #' @examples 20 | #' library("scales") 21 | #' show_col(pal_flatui("default")(10)) 22 | #' show_col(pal_flatui("flattastic")(12)) 23 | #' show_col(pal_flatui("aussie")(10)) 24 | #' show_col(pal_flatui("aussie", alpha = 0.6)(10)) 25 | pal_flatui <- function(palette = c("default", "flattastic", "aussie"), alpha = 1) { 26 | palette <- match.arg(palette) 27 | 28 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 29 | 30 | raw_cols <- ggsci_db$"flatui"[[palette]] 31 | raw_cols_rgb <- col2rgb(raw_cols) 32 | alpha_cols <- rgb( 33 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 34 | alpha = alpha * 255L, names = names(raw_cols), 35 | maxColorValue = 255L 36 | ) 37 | 38 | manual_pal(unname(alpha_cols)) 39 | } 40 | 41 | #' Flat UI color scales 42 | #' 43 | #' See [pal_flatui()] for details. 44 | #' 45 | #' @inheritParams pal_flatui 46 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 47 | #' 48 | #' @export scale_color_flatui 49 | #' 50 | #' @importFrom ggplot2 discrete_scale 51 | #' 52 | #' @author Clara Jégousse | \email{cat3@hi.is} 53 | #' 54 | #' @rdname scale_flatui 55 | #' 56 | #' @examples 57 | #' library("ggplot2") 58 | #' data("diamonds") 59 | #' 60 | #' p1 <- ggplot( 61 | #' subset(diamonds, carat >= 2.2), 62 | #' aes(x = table, y = price, colour = cut) 63 | #' ) + 64 | #' geom_point(alpha = 0.7) + 65 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 66 | #' theme_bw() 67 | #' 68 | #' p2 <- ggplot( 69 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 70 | #' aes(x = depth, fill = cut) 71 | #' ) + 72 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 73 | #' theme_bw() 74 | #' 75 | #' p1 + scale_color_flatui() 76 | #' p2 + scale_fill_flatui() 77 | #' 78 | #' p1 + scale_color_flatui(palette = "default") 79 | #' p2 + scale_fill_flatui(palette = "default") 80 | #' 81 | #' p1 + scale_color_flatui(palette = "flattastic") 82 | #' p2 + scale_fill_flatui(palette = "flattastic") 83 | #' 84 | #' p1 + scale_color_flatui(palette = "aussie") 85 | #' p2 + scale_fill_flatui(palette = "aussie") 86 | scale_color_flatui <- function(palette = c("default", "flattastic", "aussie"), alpha = 1, ...) { 87 | palette <- match.arg(palette) 88 | if (is_ggplot2_350()) { 89 | discrete_scale("colour", palette = pal_flatui(palette, alpha), ...) 90 | } else { 91 | discrete_scale("colour", scale_name = "flatui", palette = pal_flatui(palette, alpha), ...) 92 | } 93 | } 94 | 95 | #' @export scale_colour_flatui 96 | #' @rdname scale_flatui 97 | scale_colour_flatui <- scale_color_flatui 98 | 99 | #' @export scale_fill_flatui 100 | #' @importFrom ggplot2 discrete_scale 101 | #' @rdname scale_flatui 102 | scale_fill_flatui <- function(palette = c("default", "flattastic", "aussie"), alpha = 1, ...) { 103 | palette <- match.arg(palette) 104 | if (is_ggplot2_350()) { 105 | discrete_scale("fill", palette = pal_flatui(palette, alpha), ...) 106 | } else { 107 | discrete_scale("fill", scale_name = "flatui", palette = pal_flatui(palette, alpha), ...) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /R/discrete-frontiers.R: -------------------------------------------------------------------------------- 1 | #' Frontiers journal color palettes 2 | #' 3 | #' Color palettes inspired by the colors used in _Frontiers_ journals. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"default"` 7 | #' (10-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_frontiers 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Clara Jégousse | \email{cat3@hi.is} 17 | #' 18 | #' @examples 19 | #' library("scales") 20 | #' show_col(pal_frontiers("default")(7)) 21 | #' show_col(pal_frontiers("default", alpha = 0.6)(7)) 22 | pal_frontiers <- function(palette = c("default"), alpha = 1) { 23 | palette <- match.arg(palette) 24 | 25 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 26 | 27 | raw_cols <- ggsci_db$"frontiers"[[palette]] 28 | raw_cols_rgb <- col2rgb(raw_cols) 29 | alpha_cols <- rgb( 30 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 31 | alpha = alpha * 255L, names = names(raw_cols), 32 | maxColorValue = 255L 33 | ) 34 | 35 | manual_pal(unname(alpha_cols)) 36 | } 37 | 38 | #' Frontiers journal color scales 39 | #' 40 | #' See [pal_frontiers()] for details. 41 | #' 42 | #' @inheritParams pal_frontiers 43 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 44 | #' 45 | #' @export scale_color_frontiers 46 | #' 47 | #' @importFrom ggplot2 discrete_scale 48 | #' 49 | #' @author Clara Jégousse | \email{cat3@hi.is} 50 | #' 51 | #' @rdname scale_frontiers 52 | #' 53 | #' @examples 54 | #' library("ggplot2") 55 | #' data("diamonds") 56 | #' 57 | #' ggplot( 58 | #' subset(diamonds, carat >= 2.2), 59 | #' aes(x = table, y = price, colour = cut) 60 | #' ) + 61 | #' geom_point(alpha = 0.7) + 62 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 63 | #' theme_dark() + 64 | #' theme( 65 | #' panel.background = element_rect(fill = "#2D2D2D"), 66 | #' legend.key = element_rect(fill = "#2D2D2D") 67 | #' ) + 68 | #' scale_color_frontiers() 69 | #' 70 | #' ggplot( 71 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 72 | #' aes(x = depth, fill = cut) 73 | #' ) + 74 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 75 | #' theme_dark() + 76 | #' theme( 77 | #' panel.background = element_rect(fill = "#2D2D2D") 78 | #' ) + 79 | #' scale_fill_frontiers() 80 | scale_color_frontiers <- function(palette = c("default"), alpha = 1, ...) { 81 | palette <- match.arg(palette) 82 | if (is_ggplot2_350()) { 83 | discrete_scale("colour", palette = pal_frontiers(palette, alpha), ...) 84 | } else { 85 | discrete_scale("colour", scale_name = "frontiers", palette = pal_frontiers(palette, alpha), ...) 86 | } 87 | } 88 | 89 | #' @export scale_colour_frontiers 90 | #' @rdname scale_frontiers 91 | scale_colour_frontiers <- scale_color_frontiers 92 | 93 | #' @export scale_fill_frontiers 94 | #' @importFrom ggplot2 discrete_scale 95 | #' @rdname scale_frontiers 96 | scale_fill_frontiers <- function(palette = c("default"), alpha = 1, ...) { 97 | palette <- match.arg(palette) 98 | if (is_ggplot2_350()) { 99 | discrete_scale("fill", palette = pal_frontiers(palette, alpha), ...) 100 | } else { 101 | discrete_scale("fill", scale_name = "frontiers", palette = pal_frontiers(palette, alpha), ...) 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /R/discrete-futurama.R: -------------------------------------------------------------------------------- 1 | #' Futurama color palettes 2 | #' 3 | #' Color palettes inspired by the colors used in _Futurama_. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"planetexpress"` 7 | #' (12-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_futurama 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @examples 19 | #' library("scales") 20 | #' show_col(pal_futurama("planetexpress")(12)) 21 | #' show_col(pal_futurama("planetexpress", alpha = 0.6)(12)) 22 | pal_futurama <- function(palette = c("planetexpress"), alpha = 1) { 23 | palette <- match.arg(palette) 24 | 25 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 26 | 27 | raw_cols <- ggsci_db$"futurama"[[palette]] 28 | raw_cols_rgb <- col2rgb(raw_cols) 29 | alpha_cols <- rgb( 30 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 31 | alpha = alpha * 255L, names = names(raw_cols), 32 | maxColorValue = 255L 33 | ) 34 | 35 | manual_pal(unname(alpha_cols)) 36 | } 37 | 38 | #' Futurama color scales 39 | #' 40 | #' See [pal_futurama()] for details. 41 | #' 42 | #' @inheritParams pal_futurama 43 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 44 | #' 45 | #' @export scale_color_futurama 46 | #' 47 | #' @importFrom ggplot2 discrete_scale 48 | #' 49 | #' @author Nan Xiao | \email{me@nanx.me} | 50 | #' 51 | #' @rdname scale_futurama 52 | #' 53 | #' @examples 54 | #' library("ggplot2") 55 | #' data("diamonds") 56 | #' 57 | #' ggplot( 58 | #' subset(diamonds, carat >= 2.2), 59 | #' aes(x = table, y = price, colour = cut) 60 | #' ) + 61 | #' geom_point(alpha = 0.7) + 62 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 63 | #' theme_bw() + 64 | #' scale_color_futurama() 65 | #' 66 | #' ggplot( 67 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 68 | #' aes(x = depth, fill = cut) 69 | #' ) + 70 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 71 | #' theme_bw() + 72 | #' scale_fill_futurama() 73 | scale_color_futurama <- function(palette = c("planetexpress"), alpha = 1, ...) { 74 | palette <- match.arg(palette) 75 | if (is_ggplot2_350()) { 76 | discrete_scale("colour", palette = pal_futurama(palette, alpha), ...) 77 | } else { 78 | discrete_scale("colour", scale_name = "futurama", palette = pal_futurama(palette, alpha), ...) 79 | } 80 | } 81 | 82 | #' @export scale_colour_futurama 83 | #' @rdname scale_futurama 84 | scale_colour_futurama <- scale_color_futurama 85 | 86 | #' @export scale_fill_futurama 87 | #' @importFrom ggplot2 discrete_scale 88 | #' @rdname scale_futurama 89 | scale_fill_futurama <- function(palette = c("planetexpress"), alpha = 1, ...) { 90 | palette <- match.arg(palette) 91 | if (is_ggplot2_350()) { 92 | discrete_scale("fill", palette = pal_futurama(palette, alpha), ...) 93 | } else { 94 | discrete_scale("fill", scale_name = "futurama", palette = pal_futurama(palette, alpha), ...) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /R/discrete-igv.R: -------------------------------------------------------------------------------- 1 | #' Integrative Genomics Viewer (IGV) color palettes 2 | #' 3 | #' Color palettes based on the colors used by 4 | #' Integrative Genomics Viewer (IGV). 5 | #' 6 | #' @param palette Palette type. 7 | #' There are two available options: 8 | #' - `"default"` (51-color palette). 9 | #' - `"alternating"` (2-color palette). 10 | #' @param alpha Transparency level, a real number in (0, 1]. 11 | #' See `alpha` in [grDevices::rgb()] for details. 12 | #' 13 | #' @export pal_igv 14 | #' 15 | #' @importFrom grDevices col2rgb rgb 16 | #' @importFrom scales manual_pal 17 | #' 18 | #' @author Nan Xiao | \email{me@nanx.me} | 19 | #' 20 | #' @references 21 | #' James T. Robinson, Helga Thorvaldsdóttir, Wendy Winckler, 22 | #' Mitchell Guttman, Eric S. Lander, Gad Getz, Jill P. Mesirov. 23 | #' Integrative Genomics Viewer. _Nature Biotechnology_ 29, 24--26 (2011). 24 | #' 25 | #' @examples 26 | #' library("scales") 27 | #' show_col(pal_igv("default")(51)) 28 | #' show_col(pal_igv("alternating")(2)) 29 | pal_igv <- function(palette = c("default", "alternating"), alpha = 1) { 30 | palette <- match.arg(palette) 31 | 32 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 33 | 34 | raw_cols <- ggsci_db$"igv"[[palette]] 35 | raw_cols_rgb <- col2rgb(raw_cols) 36 | alpha_cols <- rgb( 37 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 38 | alpha = alpha * 255L, names = names(raw_cols), 39 | maxColorValue = 255L 40 | ) 41 | 42 | manual_pal(unname(alpha_cols)) 43 | } 44 | 45 | #' Integrative Genomics Viewer (IGV) color scales 46 | #' 47 | #' See [pal_igv()] for details. 48 | #' 49 | #' @inheritParams pal_igv 50 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 51 | #' 52 | #' @export scale_color_igv 53 | #' 54 | #' @importFrom ggplot2 discrete_scale 55 | #' 56 | #' @author Nan Xiao | \email{me@nanx.me} | 57 | #' 58 | #' @rdname scale_igv 59 | #' 60 | #' @examples 61 | #' library("ggplot2") 62 | #' data("diamonds") 63 | #' 64 | #' p1 <- ggplot( 65 | #' subset(diamonds, carat >= 2.2), 66 | #' aes(x = table, y = price, colour = cut) 67 | #' ) + 68 | #' geom_point(alpha = 0.7) + 69 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 70 | #' theme_bw() 71 | #' 72 | #' p2 <- ggplot( 73 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 74 | #' aes(x = depth, fill = cut) 75 | #' ) + 76 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 77 | #' theme_bw() 78 | #' 79 | #' p1 + scale_color_igv() 80 | #' p2 + scale_fill_igv() 81 | #' 82 | #' p1 + scale_colour_manual( 83 | #' values = rep(pal_igv("alternating")(2), times = 3) 84 | #' ) 85 | #' p2 + scale_fill_manual( 86 | #' values = rep(pal_igv("alternating")(2), times = 3) 87 | #' ) 88 | scale_color_igv <- function(palette = c("default", "alternating"), alpha = 1, ...) { 89 | palette <- match.arg(palette) 90 | if (is_ggplot2_350()) { 91 | discrete_scale("colour", palette = pal_igv(palette, alpha), ...) 92 | } else { 93 | discrete_scale("colour", scale_name = "igv", palette = pal_igv(palette, alpha), ...) 94 | } 95 | } 96 | 97 | #' @export scale_colour_igv 98 | #' @rdname scale_igv 99 | scale_colour_igv <- scale_color_igv 100 | 101 | #' @export scale_fill_igv 102 | #' @importFrom ggplot2 discrete_scale 103 | #' @rdname scale_igv 104 | scale_fill_igv <- function(palette = c("default", "alternating"), alpha = 1, ...) { 105 | palette <- match.arg(palette) 106 | if (is_ggplot2_350()) { 107 | discrete_scale("fill", palette = pal_igv(palette, alpha), ...) 108 | } else { 109 | discrete_scale("fill", scale_name = "igv", palette = pal_igv(palette, alpha), ...) 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /R/discrete-jama.R: -------------------------------------------------------------------------------- 1 | #' Journal of the American Medical Association color palettes 2 | #' 3 | #' Color palette inspired by plots in 4 | #' _The Journal of the American Medical Association_. 5 | #' 6 | #' @param palette Palette type. 7 | #' Currently there is one available option: `"default"` 8 | #' (7-color palette). 9 | #' @param alpha Transparency level, a real number in (0, 1]. 10 | #' See `alpha` in [grDevices::rgb()] for details. 11 | #' 12 | #' @export pal_jama 13 | #' 14 | #' @importFrom grDevices col2rgb rgb 15 | #' @importFrom scales manual_pal 16 | #' 17 | #' @author Nan Xiao | \email{me@nanx.me} | 18 | #' 19 | #' @examples 20 | #' library("scales") 21 | #' show_col(pal_jama("default")(7)) 22 | #' show_col(pal_jama("default", alpha = 0.6)(7)) 23 | pal_jama <- function(palette = c("default"), alpha = 1) { 24 | palette <- match.arg(palette) 25 | 26 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 27 | 28 | raw_cols <- ggsci_db$"jama"[[palette]] 29 | raw_cols_rgb <- col2rgb(raw_cols) 30 | alpha_cols <- rgb( 31 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 32 | alpha = alpha * 255L, names = names(raw_cols), 33 | maxColorValue = 255L 34 | ) 35 | 36 | manual_pal(unname(alpha_cols)) 37 | } 38 | 39 | #' Journal of the American Medical Association color scales 40 | #' 41 | #' See [pal_jama()] for details. 42 | #' 43 | #' @inheritParams pal_jama 44 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 45 | #' 46 | #' @export scale_color_jama 47 | #' 48 | #' @importFrom ggplot2 discrete_scale 49 | #' 50 | #' @author Nan Xiao | \email{me@nanx.me} | 51 | #' 52 | #' @rdname scale_jama 53 | #' 54 | #' @examples 55 | #' library("ggplot2") 56 | #' data("diamonds") 57 | #' 58 | #' ggplot( 59 | #' subset(diamonds, carat >= 2.2), 60 | #' aes(x = table, y = price, colour = cut) 61 | #' ) + 62 | #' geom_point(alpha = 0.7) + 63 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 64 | #' theme_bw() + 65 | #' scale_color_jama() 66 | #' 67 | #' ggplot( 68 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 69 | #' aes(x = depth, fill = cut) 70 | #' ) + 71 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 72 | #' theme_bw() + 73 | #' scale_fill_jama() 74 | scale_color_jama <- function(palette = c("default"), alpha = 1, ...) { 75 | palette <- match.arg(palette) 76 | if (is_ggplot2_350()) { 77 | discrete_scale("colour", palette = pal_jama(palette, alpha), ...) 78 | } else { 79 | discrete_scale("colour", scale_name = "jama", palette = pal_jama(palette, alpha), ...) 80 | } 81 | } 82 | 83 | #' @export scale_colour_jama 84 | #' @rdname scale_jama 85 | scale_colour_jama <- scale_color_jama 86 | 87 | #' @export scale_fill_jama 88 | #' @importFrom ggplot2 discrete_scale 89 | #' @rdname scale_jama 90 | scale_fill_jama <- function(palette = c("default"), alpha = 1, ...) { 91 | palette <- match.arg(palette) 92 | if (is_ggplot2_350()) { 93 | discrete_scale("fill", palette = pal_jama(palette, alpha), ...) 94 | } else { 95 | discrete_scale("fill", scale_name = "jama", palette = pal_jama(palette, alpha), ...) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /R/discrete-jco.R: -------------------------------------------------------------------------------- 1 | #' Journal of Clinical Oncology color palettes 2 | #' 3 | #' Color palette inspired by plots in _Journal of Clinical Oncology_. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"default"` 7 | #' (10-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_jco 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @examples 19 | #' library("scales") 20 | #' show_col(pal_jco("default")(10)) 21 | #' show_col(pal_jco("default", alpha = 0.6)(10)) 22 | pal_jco <- function(palette = c("default"), alpha = 1) { 23 | palette <- match.arg(palette) 24 | 25 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 26 | 27 | raw_cols <- ggsci_db$"jco"[[palette]] 28 | raw_cols_rgb <- col2rgb(raw_cols) 29 | alpha_cols <- rgb( 30 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 31 | alpha = alpha * 255L, names = names(raw_cols), 32 | maxColorValue = 255L 33 | ) 34 | 35 | manual_pal(unname(alpha_cols)) 36 | } 37 | 38 | #' Journal of Clinical Oncology color scales 39 | #' 40 | #' See [pal_jco()] for details. 41 | #' 42 | #' @inheritParams pal_jco 43 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 44 | #' 45 | #' @export scale_color_jco 46 | #' 47 | #' @importFrom ggplot2 discrete_scale 48 | #' 49 | #' @author Nan Xiao | \email{me@nanx.me} | 50 | #' 51 | #' @rdname scale_jco 52 | #' 53 | #' @examples 54 | #' library("ggplot2") 55 | #' data("diamonds") 56 | #' 57 | #' ggplot( 58 | #' subset(diamonds, carat >= 2.2), 59 | #' aes(x = table, y = price, colour = cut) 60 | #' ) + 61 | #' geom_point(alpha = 0.7) + 62 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 63 | #' theme_bw() + 64 | #' scale_color_jco() 65 | #' 66 | #' ggplot( 67 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 68 | #' aes(x = depth, fill = cut) 69 | #' ) + 70 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 71 | #' theme_bw() + 72 | #' scale_fill_jco() 73 | scale_color_jco <- function(palette = c("default"), alpha = 1, ...) { 74 | palette <- match.arg(palette) 75 | if (is_ggplot2_350()) { 76 | discrete_scale("colour", palette = pal_jco(palette, alpha), ...) 77 | } else { 78 | discrete_scale("colour", scale_name = "jco", palette = pal_jco(palette, alpha), ...) 79 | } 80 | } 81 | 82 | #' @export scale_colour_jco 83 | #' @rdname scale_jco 84 | scale_colour_jco <- scale_color_jco 85 | 86 | #' @export scale_fill_jco 87 | #' @importFrom ggplot2 discrete_scale 88 | #' @rdname scale_jco 89 | scale_fill_jco <- function(palette = c("default"), alpha = 1, ...) { 90 | palette <- match.arg(palette) 91 | if (is_ggplot2_350()) { 92 | discrete_scale("fill", palette = pal_jco(palette, alpha), ...) 93 | } else { 94 | discrete_scale("fill", scale_name = "jco", palette = pal_jco(palette, alpha), ...) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /R/discrete-lancet.R: -------------------------------------------------------------------------------- 1 | #' Lancet journal color palettes 2 | #' 3 | #' Color palettes inspired by plots in Lancet journals, 4 | #' such as _Lancet Oncology_. 5 | #' 6 | #' @param palette Palette type. 7 | #' Currently there is one available option: `"lanonc"` 8 | #' (9-color palette inspired by _Lancet Oncology_). 9 | #' @param alpha Transparency level, a real number in (0, 1]. 10 | #' See `alpha` in [grDevices::rgb()] for details. 11 | #' 12 | #' @export pal_lancet 13 | #' 14 | #' @importFrom grDevices col2rgb rgb 15 | #' @importFrom scales manual_pal 16 | #' 17 | #' @author Nan Xiao | \email{me@nanx.me} | 18 | #' 19 | #' @examples 20 | #' library("scales") 21 | #' show_col(pal_lancet("lanonc")(9)) 22 | #' show_col(pal_lancet("lanonc", alpha = 0.6)(9)) 23 | pal_lancet <- function(palette = c("lanonc"), alpha = 1) { 24 | palette <- match.arg(palette) 25 | 26 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 27 | 28 | raw_cols <- ggsci_db$"lancet"[[palette]] 29 | raw_cols_rgb <- col2rgb(raw_cols) 30 | alpha_cols <- rgb( 31 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 32 | alpha = alpha * 255L, names = names(raw_cols), 33 | maxColorValue = 255L 34 | ) 35 | 36 | manual_pal(unname(alpha_cols)) 37 | } 38 | 39 | #' Lancet journal color scales 40 | #' 41 | #' See [pal_lancet()] for details. 42 | #' 43 | #' @inheritParams pal_lancet 44 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 45 | #' 46 | #' @export scale_color_lancet 47 | #' 48 | #' @importFrom ggplot2 discrete_scale 49 | #' 50 | #' @author Nan Xiao | \email{me@nanx.me} | 51 | #' 52 | #' @rdname scale_lancet 53 | #' 54 | #' @examples 55 | #' library("ggplot2") 56 | #' data("diamonds") 57 | #' 58 | #' ggplot( 59 | #' subset(diamonds, carat >= 2.2), 60 | #' aes(x = table, y = price, colour = cut) 61 | #' ) + 62 | #' geom_point(alpha = 0.7) + 63 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 64 | #' theme_bw() + 65 | #' scale_color_lancet() 66 | #' 67 | #' ggplot( 68 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 69 | #' aes(x = depth, fill = cut) 70 | #' ) + 71 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 72 | #' theme_bw() + 73 | #' scale_fill_lancet() 74 | scale_color_lancet <- function(palette = c("lanonc"), alpha = 1, ...) { 75 | palette <- match.arg(palette) 76 | if (is_ggplot2_350()) { 77 | discrete_scale("colour", palette = pal_lancet(palette, alpha), ...) 78 | } else { 79 | discrete_scale("colour", scale_name = "lancet", palette = pal_lancet(palette, alpha), ...) 80 | } 81 | } 82 | 83 | #' @export scale_colour_lancet 84 | #' @rdname scale_lancet 85 | scale_colour_lancet <- scale_color_lancet 86 | 87 | #' @export scale_fill_lancet 88 | #' @importFrom ggplot2 discrete_scale 89 | #' @rdname scale_lancet 90 | scale_fill_lancet <- function(palette = c("lanonc"), alpha = 1, ...) { 91 | palette <- match.arg(palette) 92 | if (is_ggplot2_350()) { 93 | discrete_scale("fill", palette = pal_lancet(palette, alpha), ...) 94 | } else { 95 | discrete_scale("fill", scale_name = "lancet", palette = pal_lancet(palette, alpha), ...) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /R/discrete-locuszoom.R: -------------------------------------------------------------------------------- 1 | #' LocusZoom color palette 2 | #' 3 | #' Color palettes based on the colors used by LocusZoom. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"default"` 7 | #' (7-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_locuszoom 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @references 19 | #' Pruim, Randall J., et al. (2010). LocusZoom: regional visualization of 20 | #' genome-wide association scan results. _Bioinformatics_, 21 | #' 26(18), 2336--2337. 22 | #' 23 | #' @examples 24 | #' library("scales") 25 | #' show_col(pal_locuszoom("default")(7)) 26 | #' show_col(pal_locuszoom("default", alpha = 0.6)(7)) 27 | pal_locuszoom <- function(palette = c("default"), alpha = 1) { 28 | palette <- match.arg(palette) 29 | 30 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 31 | 32 | raw_cols <- ggsci_db$"locuszoom"[[palette]] 33 | raw_cols_rgb <- col2rgb(raw_cols) 34 | alpha_cols <- rgb( 35 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 36 | alpha = alpha * 255L, names = names(raw_cols), 37 | maxColorValue = 255L 38 | ) 39 | 40 | manual_pal(unname(alpha_cols)) 41 | } 42 | 43 | #' LocusZoom color scales 44 | #' 45 | #' See [pal_locuszoom()] for details. 46 | #' 47 | #' @inheritParams pal_locuszoom 48 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 49 | #' 50 | #' @export scale_color_locuszoom 51 | #' 52 | #' @importFrom ggplot2 discrete_scale 53 | #' 54 | #' @author Nan Xiao | \email{me@nanx.me} | 55 | #' 56 | #' @rdname scale_locuszoom 57 | #' 58 | #' @examples 59 | #' library("ggplot2") 60 | #' data("diamonds") 61 | #' 62 | #' ggplot( 63 | #' subset(diamonds, carat >= 2.2), 64 | #' aes(x = table, y = price, colour = cut) 65 | #' ) + 66 | #' geom_point(alpha = 0.7) + 67 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 68 | #' theme_bw() + 69 | #' scale_color_locuszoom() 70 | #' 71 | #' ggplot( 72 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 73 | #' aes(x = depth, fill = cut) 74 | #' ) + 75 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 76 | #' theme_bw() + 77 | #' scale_fill_locuszoom() 78 | scale_color_locuszoom <- function(palette = c("default"), alpha = 1, ...) { 79 | palette <- match.arg(palette) 80 | if (is_ggplot2_350()) { 81 | discrete_scale("colour", palette = pal_locuszoom(palette, alpha), ...) 82 | } else { 83 | discrete_scale("colour", scale_name = "locuszoom", palette = pal_locuszoom(palette, alpha), ...) 84 | } 85 | } 86 | 87 | #' @export scale_colour_locuszoom 88 | #' @rdname scale_locuszoom 89 | scale_colour_locuszoom <- scale_color_locuszoom 90 | 91 | #' @export scale_fill_locuszoom 92 | #' @importFrom ggplot2 discrete_scale 93 | #' @rdname scale_locuszoom 94 | scale_fill_locuszoom <- function(palette = c("default"), alpha = 1, ...) { 95 | palette <- match.arg(palette) 96 | if (is_ggplot2_350()) { 97 | discrete_scale("fill", palette = pal_locuszoom(palette, alpha), ...) 98 | } else { 99 | discrete_scale("fill", scale_name = "locuszoom", palette = pal_locuszoom(palette, alpha), ...) 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /R/discrete-nejm.R: -------------------------------------------------------------------------------- 1 | #' NEJM color palettes 2 | #' 3 | #' Color palette inspired by plots in 4 | #' _The New England Journal of Medicine_. 5 | #' 6 | #' @param palette Palette type. 7 | #' Currently there is one available option: `"default"` 8 | #' (8-color palette). 9 | #' @param alpha Transparency level, a real number in (0, 1]. 10 | #' See `alpha` in [grDevices::rgb()] for details. 11 | #' 12 | #' @export pal_nejm 13 | #' 14 | #' @importFrom grDevices col2rgb rgb 15 | #' @importFrom scales manual_pal 16 | #' 17 | #' @author Nan Xiao | \email{me@nanx.me} | 18 | #' 19 | #' @examples 20 | #' library("scales") 21 | #' show_col(pal_nejm("default")(8)) 22 | #' show_col(pal_nejm("default", alpha = 0.6)(8)) 23 | pal_nejm <- function(palette = c("default"), alpha = 1) { 24 | palette <- match.arg(palette) 25 | 26 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 27 | 28 | raw_cols <- ggsci_db$"nejm"[[palette]] 29 | raw_cols_rgb <- col2rgb(raw_cols) 30 | alpha_cols <- rgb( 31 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 32 | alpha = alpha * 255L, names = names(raw_cols), 33 | maxColorValue = 255L 34 | ) 35 | 36 | manual_pal(unname(alpha_cols)) 37 | } 38 | 39 | #' NEJM color scales 40 | #' 41 | #' See [pal_nejm()] for details. 42 | #' 43 | #' @inheritParams pal_nejm 44 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 45 | #' 46 | #' @export scale_color_nejm 47 | #' 48 | #' @importFrom ggplot2 discrete_scale 49 | #' 50 | #' @author Nan Xiao | \email{me@nanx.me} | 51 | #' 52 | #' @rdname scale_nejm 53 | #' 54 | #' @examples 55 | #' library("ggplot2") 56 | #' data("diamonds") 57 | #' 58 | #' ggplot( 59 | #' subset(diamonds, carat >= 2.2), 60 | #' aes(x = table, y = price, colour = cut) 61 | #' ) + 62 | #' geom_point(alpha = 0.7) + 63 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 64 | #' theme_bw() + 65 | #' scale_color_nejm() 66 | #' 67 | #' ggplot( 68 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 69 | #' aes(x = depth, fill = cut) 70 | #' ) + 71 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 72 | #' theme_bw() + 73 | #' scale_fill_nejm() 74 | scale_color_nejm <- function(palette = c("default"), alpha = 1, ...) { 75 | palette <- match.arg(palette) 76 | if (is_ggplot2_350()) { 77 | discrete_scale("colour", palette = pal_nejm(palette, alpha), ...) 78 | } else { 79 | discrete_scale("colour", scale_name = "nejm", palette = pal_nejm(palette, alpha), ...) 80 | } 81 | } 82 | 83 | #' @export scale_colour_nejm 84 | #' @rdname scale_nejm 85 | scale_colour_nejm <- scale_color_nejm 86 | 87 | #' @export scale_fill_nejm 88 | #' @importFrom ggplot2 discrete_scale 89 | #' @rdname scale_nejm 90 | scale_fill_nejm <- function(palette = c("default"), alpha = 1, ...) { 91 | palette <- match.arg(palette) 92 | if (is_ggplot2_350()) { 93 | discrete_scale("fill", palette = pal_nejm(palette, alpha), ...) 94 | } else { 95 | discrete_scale("fill", scale_name = "nejm", palette = pal_nejm(palette, alpha), ...) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /R/discrete-npg.R: -------------------------------------------------------------------------------- 1 | #' NPG journal color palettes 2 | #' 3 | #' Color palettes inspired by plots in journals published by 4 | #' Nature Publishing Group, such as _Nature Reviews Cancer_. 5 | #' 6 | #' @param palette Palette type. 7 | #' Currently there is one available option: `"nrc"` 8 | #' (10-color palette inspired by _Nature Reviews Cancer_). 9 | #' @param alpha Transparency level, a real number in (0, 1]. 10 | #' See `alpha` in [grDevices::rgb()] for details. 11 | #' 12 | #' @export pal_npg 13 | #' 14 | #' @importFrom grDevices col2rgb rgb 15 | #' @importFrom scales manual_pal 16 | #' 17 | #' @author Nan Xiao | \email{me@nanx.me} | 18 | #' 19 | #' @examples 20 | #' library("scales") 21 | #' show_col(pal_npg("nrc")(10)) 22 | #' show_col(pal_npg("nrc", alpha = 0.6)(10)) 23 | pal_npg <- function(palette = c("nrc"), alpha = 1) { 24 | palette <- match.arg(palette) 25 | 26 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 27 | 28 | raw_cols <- ggsci_db$"npg"[[palette]] 29 | raw_cols_rgb <- col2rgb(raw_cols) 30 | alpha_cols <- rgb( 31 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 32 | alpha = alpha * 255L, names = names(raw_cols), 33 | maxColorValue = 255L 34 | ) 35 | 36 | manual_pal(unname(alpha_cols)) 37 | } 38 | 39 | #' NPG journal color scales 40 | #' 41 | #' See [pal_npg()] for details. 42 | #' 43 | #' @inheritParams pal_npg 44 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 45 | #' 46 | #' @export scale_color_npg 47 | #' 48 | #' @importFrom ggplot2 discrete_scale 49 | #' 50 | #' @author Nan Xiao | \email{me@nanx.me} | 51 | #' 52 | #' @rdname scale_npg 53 | #' 54 | #' @examples 55 | #' library("ggplot2") 56 | #' data("diamonds") 57 | #' 58 | #' ggplot( 59 | #' subset(diamonds, carat >= 2.2), 60 | #' aes(x = table, y = price, colour = cut) 61 | #' ) + 62 | #' geom_point(alpha = 0.7) + 63 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 64 | #' theme_bw() + 65 | #' scale_color_npg() 66 | #' 67 | #' ggplot( 68 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 69 | #' aes(x = depth, fill = cut) 70 | #' ) + 71 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 72 | #' theme_bw() + 73 | #' scale_fill_npg() 74 | scale_color_npg <- function(palette = c("nrc"), alpha = 1, ...) { 75 | palette <- match.arg(palette) 76 | if (is_ggplot2_350()) { 77 | discrete_scale("colour", palette = pal_npg(palette, alpha), ...) 78 | } else { 79 | discrete_scale("colour", scale_name = "npg", palette = pal_npg(palette, alpha), ...) 80 | } 81 | } 82 | 83 | #' @export scale_colour_npg 84 | #' @rdname scale_npg 85 | scale_colour_npg <- scale_color_npg 86 | 87 | #' @export scale_fill_npg 88 | #' @importFrom ggplot2 discrete_scale 89 | #' @rdname scale_npg 90 | scale_fill_npg <- function(palette = c("nrc"), alpha = 1, ...) { 91 | palette <- match.arg(palette) 92 | if (is_ggplot2_350()) { 93 | discrete_scale("fill", palette = pal_npg(palette, alpha), ...) 94 | } else { 95 | discrete_scale("fill", scale_name = "npg", palette = pal_npg(palette, alpha), ...) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /R/discrete-observable.R: -------------------------------------------------------------------------------- 1 | #' Observable 10 color palette 2 | #' 3 | #' The Observable 10 palette. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"observable10"` 7 | #' (10-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_observable 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @references 19 | #' Pettiross J (2023). "Crafting data colors and staying on brand." 20 | #' _Observable blog_. 21 | #' 22 | #' @examples 23 | #' library("scales") 24 | #' show_col(pal_observable("observable10")(10)) 25 | #' show_col(pal_observable("observable10", alpha = 0.6)(10)) 26 | pal_observable <- function(palette = c("observable10"), alpha = 1) { 27 | palette <- match.arg(palette) 28 | 29 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 30 | 31 | raw_cols <- ggsci_db$"observable"[[palette]] 32 | raw_cols_rgb <- col2rgb(raw_cols) 33 | alpha_cols <- rgb( 34 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 35 | alpha = alpha * 255L, names = names(raw_cols), 36 | maxColorValue = 255L 37 | ) 38 | 39 | manual_pal(unname(alpha_cols)) 40 | } 41 | 42 | #' Observable 10 color scales 43 | #' 44 | #' See [pal_observable()] for details. 45 | #' 46 | #' @inheritParams pal_observable 47 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 48 | #' 49 | #' @export scale_color_observable 50 | #' 51 | #' @importFrom ggplot2 discrete_scale 52 | #' 53 | #' @author Nan Xiao | \email{me@nanx.me} | 54 | #' 55 | #' @references 56 | #' Pettiross J (2023). "Crafting data colors and staying on brand." 57 | #' _Observable blog_. 58 | #' 59 | #' @rdname scale_observable 60 | #' 61 | #' @examples 62 | #' library("ggplot2") 63 | #' data("diamonds") 64 | #' 65 | #' ggplot( 66 | #' subset(diamonds, carat >= 2.2), 67 | #' aes(x = table, y = price, colour = cut) 68 | #' ) + 69 | #' geom_point(alpha = 0.7) + 70 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 71 | #' theme_bw() + 72 | #' scale_color_observable() 73 | #' 74 | #' ggplot( 75 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 76 | #' aes(x = depth, fill = cut) 77 | #' ) + 78 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 79 | #' theme_bw() + 80 | #' scale_fill_observable() 81 | scale_color_observable <- function(palette = c("observable10"), alpha = 1, ...) { 82 | palette <- match.arg(palette) 83 | if (is_ggplot2_350()) { 84 | discrete_scale("colour", palette = pal_observable(palette, alpha), ...) 85 | } else { 86 | discrete_scale("colour", scale_name = "observable", palette = pal_observable(palette, alpha), ...) 87 | } 88 | } 89 | 90 | #' @export scale_colour_observable 91 | #' @rdname scale_observable 92 | scale_colour_observable <- scale_color_observable 93 | 94 | #' @export scale_fill_observable 95 | #' @importFrom ggplot2 discrete_scale 96 | #' @rdname scale_observable 97 | scale_fill_observable <- function(palette = c("observable10"), alpha = 1, ...) { 98 | palette <- match.arg(palette) 99 | if (is_ggplot2_350()) { 100 | discrete_scale("fill", palette = pal_observable(palette, alpha), ...) 101 | } else { 102 | discrete_scale("fill", scale_name = "observable", palette = pal_observable(palette, alpha), ...) 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /R/discrete-rickandmorty.R: -------------------------------------------------------------------------------- 1 | #' Rick and Morty color palettes 2 | #' 3 | #' Color palettes inspired by the colors used in _Rick and Morty_. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"schwifty"` 7 | #' (12-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_rickandmorty 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @examples 19 | #' library("scales") 20 | #' show_col(pal_rickandmorty("schwifty")(12)) 21 | #' show_col(pal_rickandmorty("schwifty", alpha = 0.6)(12)) 22 | pal_rickandmorty <- function(palette = c("schwifty"), alpha = 1) { 23 | palette <- match.arg(palette) 24 | 25 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 26 | 27 | raw_cols <- ggsci_db$"rickandmorty"[[palette]] 28 | raw_cols_rgb <- col2rgb(raw_cols) 29 | alpha_cols <- rgb( 30 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 31 | alpha = alpha * 255L, names = names(raw_cols), 32 | maxColorValue = 255L 33 | ) 34 | 35 | manual_pal(unname(alpha_cols)) 36 | } 37 | 38 | #' Rick and Morty color scales 39 | #' 40 | #' See [pal_rickandmorty()] for details. 41 | #' 42 | #' @inheritParams pal_rickandmorty 43 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 44 | #' 45 | #' @export scale_color_rickandmorty 46 | #' 47 | #' @importFrom ggplot2 discrete_scale 48 | #' 49 | #' @author Nan Xiao | \email{me@nanx.me} | 50 | #' 51 | #' @rdname scale_rickandmorty 52 | #' 53 | #' @examples 54 | #' library("ggplot2") 55 | #' data("diamonds") 56 | #' 57 | #' ggplot( 58 | #' subset(diamonds, carat >= 2.2), 59 | #' aes(x = table, y = price, colour = cut) 60 | #' ) + 61 | #' geom_point(alpha = 0.7) + 62 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 63 | #' theme_bw() + 64 | #' scale_color_rickandmorty() 65 | #' 66 | #' ggplot( 67 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 68 | #' aes(x = depth, fill = cut) 69 | #' ) + 70 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 71 | #' theme_bw() + 72 | #' scale_fill_rickandmorty() 73 | scale_color_rickandmorty <- function(palette = c("schwifty"), alpha = 1, ...) { 74 | palette <- match.arg(palette) 75 | if (is_ggplot2_350()) { 76 | discrete_scale("colour", palette = pal_rickandmorty(palette, alpha), ...) 77 | } else { 78 | discrete_scale("colour", scale_name = "rickandmorty", palette = pal_rickandmorty(palette, alpha), ...) 79 | } 80 | } 81 | 82 | #' @export scale_colour_rickandmorty 83 | #' @rdname scale_rickandmorty 84 | scale_colour_rickandmorty <- scale_color_rickandmorty 85 | 86 | #' @export scale_fill_rickandmorty 87 | #' @importFrom ggplot2 discrete_scale 88 | #' @rdname scale_rickandmorty 89 | scale_fill_rickandmorty <- function(palette = c("schwifty"), alpha = 1, ...) { 90 | palette <- match.arg(palette) 91 | if (is_ggplot2_350()) { 92 | discrete_scale("fill", palette = pal_rickandmorty(palette, alpha), ...) 93 | } else { 94 | discrete_scale("fill", scale_name = "rickandmorty", palette = pal_rickandmorty(palette, alpha), ...) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /R/discrete-simpsons.R: -------------------------------------------------------------------------------- 1 | #' The Simpsons color palettes 2 | #' 3 | #' Color palettes inspired by the colors used in _The Simpsons_. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"springfield"` 7 | #' (16-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_simpsons 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @examples 19 | #' library("scales") 20 | #' show_col(pal_simpsons("springfield")(16)) 21 | #' show_col(pal_simpsons("springfield", alpha = 0.6)(16)) 22 | pal_simpsons <- function(palette = c("springfield"), alpha = 1) { 23 | palette <- match.arg(palette) 24 | 25 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 26 | 27 | raw_cols <- ggsci_db$"simpsons"[[palette]] 28 | raw_cols_rgb <- col2rgb(raw_cols) 29 | alpha_cols <- rgb( 30 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 31 | alpha = alpha * 255L, names = names(raw_cols), 32 | maxColorValue = 255L 33 | ) 34 | 35 | manual_pal(unname(alpha_cols)) 36 | } 37 | 38 | #' The Simpsons color scales 39 | #' 40 | #' See [pal_simpsons()] for details. 41 | #' 42 | #' @inheritParams pal_simpsons 43 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 44 | #' 45 | #' @export scale_color_simpsons 46 | #' 47 | #' @importFrom ggplot2 discrete_scale 48 | #' 49 | #' @author Nan Xiao | \email{me@nanx.me} | 50 | #' 51 | #' @rdname scale_simpsons 52 | #' 53 | #' @examples 54 | #' library("ggplot2") 55 | #' data("diamonds") 56 | #' 57 | #' ggplot( 58 | #' subset(diamonds, carat >= 2.2), 59 | #' aes(x = table, y = price, colour = cut) 60 | #' ) + 61 | #' geom_point(alpha = 0.7) + 62 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 63 | #' theme_bw() + 64 | #' scale_color_simpsons() 65 | #' 66 | #' ggplot( 67 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 68 | #' aes(x = depth, fill = cut) 69 | #' ) + 70 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 71 | #' theme_bw() + 72 | #' scale_fill_simpsons() 73 | scale_color_simpsons <- function(palette = c("springfield"), alpha = 1, ...) { 74 | palette <- match.arg(palette) 75 | if (is_ggplot2_350()) { 76 | discrete_scale("colour", palette = pal_simpsons(palette, alpha), ...) 77 | } else { 78 | discrete_scale("colour", scale_name = "simpsons", palette = pal_simpsons(palette, alpha), ...) 79 | } 80 | } 81 | 82 | #' @export scale_colour_simpsons 83 | #' @rdname scale_simpsons 84 | scale_colour_simpsons <- scale_color_simpsons 85 | 86 | #' @export scale_fill_simpsons 87 | #' @importFrom ggplot2 discrete_scale 88 | #' @rdname scale_simpsons 89 | scale_fill_simpsons <- function(palette = c("springfield"), alpha = 1, ...) { 90 | palette <- match.arg(palette) 91 | if (is_ggplot2_350()) { 92 | discrete_scale("fill", palette = pal_simpsons(palette, alpha), ...) 93 | } else { 94 | discrete_scale("fill", scale_name = "simpsons", palette = pal_simpsons(palette, alpha), ...) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /R/discrete-startrek.R: -------------------------------------------------------------------------------- 1 | #' Star Trek color palettes 2 | #' 3 | #' Color palettes inspired by the colors used in _Star Trek_. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"uniform"` 7 | #' (7-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_startrek 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @examples 19 | #' library("scales") 20 | #' show_col(pal_startrek("uniform")(7)) 21 | #' show_col(pal_startrek("uniform", alpha = 0.6)(7)) 22 | pal_startrek <- function(palette = c("uniform"), alpha = 1) { 23 | palette <- match.arg(palette) 24 | 25 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 26 | 27 | raw_cols <- ggsci_db$"startrek"[[palette]] 28 | raw_cols_rgb <- col2rgb(raw_cols) 29 | alpha_cols <- rgb( 30 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 31 | alpha = alpha * 255L, names = names(raw_cols), 32 | maxColorValue = 255L 33 | ) 34 | 35 | manual_pal(unname(alpha_cols)) 36 | } 37 | 38 | #' Star Trek color scales 39 | #' 40 | #' See [pal_startrek()] for details. 41 | #' 42 | #' @inheritParams pal_startrek 43 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 44 | #' 45 | #' @export scale_color_startrek 46 | #' 47 | #' @importFrom ggplot2 discrete_scale 48 | #' 49 | #' @author Nan Xiao | \email{me@nanx.me} | 50 | #' 51 | #' @rdname scale_startrek 52 | #' 53 | #' @examples 54 | #' library("ggplot2") 55 | #' data("diamonds") 56 | #' 57 | #' ggplot( 58 | #' subset(diamonds, carat >= 2.2), 59 | #' aes(x = table, y = price, colour = cut) 60 | #' ) + 61 | #' geom_point(alpha = 0.7) + 62 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 63 | #' theme_bw() + 64 | #' scale_color_startrek() 65 | #' 66 | #' ggplot( 67 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 68 | #' aes(x = depth, fill = cut) 69 | #' ) + 70 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 71 | #' theme_bw() + 72 | #' scale_fill_startrek() 73 | scale_color_startrek <- function(palette = c("uniform"), alpha = 1, ...) { 74 | palette <- match.arg(palette) 75 | if (is_ggplot2_350()) { 76 | discrete_scale("colour", palette = pal_startrek(palette, alpha), ...) 77 | } else { 78 | discrete_scale("colour", scale_name = "startrek", palette = pal_startrek(palette, alpha), ...) 79 | } 80 | } 81 | 82 | #' @export scale_colour_startrek 83 | #' @rdname scale_startrek 84 | scale_colour_startrek <- scale_color_startrek 85 | 86 | #' @export scale_fill_startrek 87 | #' @importFrom ggplot2 discrete_scale 88 | #' @rdname scale_startrek 89 | scale_fill_startrek <- function(palette = c("uniform"), alpha = 1, ...) { 90 | palette <- match.arg(palette) 91 | if (is_ggplot2_350()) { 92 | discrete_scale("fill", palette = pal_startrek(palette, alpha), ...) 93 | } else { 94 | discrete_scale("fill", scale_name = "startrek", palette = pal_startrek(palette, alpha), ...) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /R/discrete-tron.R: -------------------------------------------------------------------------------- 1 | #' Tron Legacy color palettes 2 | #' 3 | #' Color palettes inspired by the colors used in _Tron Legacy_. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"legacy"` 7 | #' (7-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_tron 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @examples 19 | #' library("scales") 20 | #' show_col(pal_tron("legacy")(7)) 21 | #' show_col(pal_tron("legacy", alpha = 0.6)(7)) 22 | pal_tron <- function(palette = c("legacy"), alpha = 1) { 23 | palette <- match.arg(palette) 24 | 25 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 26 | 27 | raw_cols <- ggsci_db$"tron"[[palette]] 28 | raw_cols_rgb <- col2rgb(raw_cols) 29 | alpha_cols <- rgb( 30 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 31 | alpha = alpha * 255L, names = names(raw_cols), 32 | maxColorValue = 255L 33 | ) 34 | 35 | manual_pal(unname(alpha_cols)) 36 | } 37 | 38 | #' Tron Legacy color scales 39 | #' 40 | #' See [pal_tron()] for details. 41 | #' 42 | #' @inheritParams pal_tron 43 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 44 | #' 45 | #' @export scale_color_tron 46 | #' 47 | #' @importFrom ggplot2 discrete_scale 48 | #' 49 | #' @author Nan Xiao | \email{me@nanx.me} | 50 | #' 51 | #' @rdname scale_tron 52 | #' 53 | #' @examples 54 | #' library("ggplot2") 55 | #' data("diamonds") 56 | #' 57 | #' ggplot( 58 | #' subset(diamonds, carat >= 2.2), 59 | #' aes(x = table, y = price, colour = cut) 60 | #' ) + 61 | #' geom_point(alpha = 0.7) + 62 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 63 | #' theme_dark() + 64 | #' theme( 65 | #' panel.background = element_rect(fill = "#2D2D2D"), 66 | #' legend.key = element_rect(fill = "#2D2D2D") 67 | #' ) + 68 | #' scale_color_tron() 69 | #' 70 | #' ggplot( 71 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 72 | #' aes(x = depth, fill = cut) 73 | #' ) + 74 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 75 | #' theme_dark() + 76 | #' theme( 77 | #' panel.background = element_rect(fill = "#2D2D2D") 78 | #' ) + 79 | #' scale_fill_tron() 80 | scale_color_tron <- function(palette = c("legacy"), alpha = 1, ...) { 81 | palette <- match.arg(palette) 82 | if (is_ggplot2_350()) { 83 | discrete_scale("colour", palette = pal_tron(palette, alpha), ...) 84 | } else { 85 | discrete_scale("colour", scale_name = "tron", palette = pal_tron(palette, alpha), ...) 86 | } 87 | } 88 | 89 | #' @export scale_colour_tron 90 | #' @rdname scale_tron 91 | scale_colour_tron <- scale_color_tron 92 | 93 | #' @export scale_fill_tron 94 | #' @importFrom ggplot2 discrete_scale 95 | #' @rdname scale_tron 96 | scale_fill_tron <- function(palette = c("legacy"), alpha = 1, ...) { 97 | palette <- match.arg(palette) 98 | if (is_ggplot2_350()) { 99 | discrete_scale("fill", palette = pal_tron(palette, alpha), ...) 100 | } else { 101 | discrete_scale("fill", scale_name = "tron", palette = pal_tron(palette, alpha), ...) 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /R/discrete-uchicago.R: -------------------------------------------------------------------------------- 1 | #' The University of Chicago color palettes 2 | #' 3 | #' Color palettes based on the colors used by the University of Chicago. 4 | #' 5 | #' @param palette Palette type. 6 | #' There are three available options: 7 | #' - `"default"` (9-color palette); 8 | #' - `"light"` (9-color light palette); 9 | #' - `"dark"` (9-color dark palette). 10 | #' @param alpha Transparency level, a real number in (0, 1]. 11 | #' See `alpha` in [grDevices::rgb()] for details. 12 | #' 13 | #' @export pal_uchicago 14 | #' 15 | #' @importFrom grDevices col2rgb rgb 16 | #' @importFrom scales manual_pal 17 | #' 18 | #' @author Nan Xiao | \email{me@nanx.me} | 19 | #' 20 | #' @references 21 | #' 22 | #' 23 | #' @examples 24 | #' library("scales") 25 | #' show_col(pal_uchicago("default")(9)) 26 | #' show_col(pal_uchicago("light")(9)) 27 | #' show_col(pal_uchicago("dark")(9)) 28 | pal_uchicago <- function(palette = c("default", "light", "dark"), alpha = 1) { 29 | palette <- match.arg(palette) 30 | 31 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 32 | 33 | raw_cols <- ggsci_db$"uchicago"[[palette]] 34 | raw_cols_rgb <- col2rgb(raw_cols) 35 | alpha_cols <- rgb( 36 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 37 | alpha = alpha * 255L, names = names(raw_cols), 38 | maxColorValue = 255L 39 | ) 40 | 41 | manual_pal(unname(alpha_cols)) 42 | } 43 | 44 | #' The University of Chicago color scales 45 | #' 46 | #' See [pal_uchicago()] for details. 47 | #' 48 | #' @inheritParams pal_uchicago 49 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 50 | #' 51 | #' @export scale_color_uchicago 52 | #' 53 | #' @importFrom ggplot2 discrete_scale 54 | #' 55 | #' @author Nan Xiao | \email{me@nanx.me} | 56 | #' 57 | #' @references 58 | #' 59 | #' 60 | #' @rdname scale_uchicago 61 | #' 62 | #' @examples 63 | #' library("ggplot2") 64 | #' data("diamonds") 65 | #' 66 | #' p1 <- ggplot( 67 | #' subset(diamonds, carat >= 2.2), 68 | #' aes(x = table, y = price, colour = cut) 69 | #' ) + 70 | #' geom_point(alpha = 0.7) + 71 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 72 | #' theme_bw() 73 | #' 74 | #' p2 <- ggplot( 75 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 76 | #' aes(x = depth, fill = cut) 77 | #' ) + 78 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 79 | #' theme_bw() 80 | #' 81 | #' p1 + scale_color_uchicago() 82 | #' p2 + scale_fill_uchicago() 83 | #' 84 | #' p1 + scale_color_uchicago(palette = "light") 85 | #' p2 + scale_fill_uchicago(palette = "light") 86 | #' 87 | #' p1 + scale_color_uchicago(palette = "dark") 88 | #' p2 + scale_fill_uchicago(palette = "dark") 89 | scale_color_uchicago <- function(palette = c("default", "light", "dark"), alpha = 1, ...) { 90 | palette <- match.arg(palette) 91 | if (is_ggplot2_350()) { 92 | discrete_scale("colour", palette = pal_uchicago(palette, alpha), ...) 93 | } else { 94 | discrete_scale("colour", scale_name = "uchicago", palette = pal_uchicago(palette, alpha), ...) 95 | } 96 | } 97 | 98 | #' @export scale_colour_uchicago 99 | #' @rdname scale_uchicago 100 | scale_colour_uchicago <- scale_color_uchicago 101 | 102 | #' @export scale_fill_uchicago 103 | #' @importFrom ggplot2 discrete_scale 104 | #' @rdname scale_uchicago 105 | scale_fill_uchicago <- function(palette = c("default", "light", "dark"), alpha = 1, ...) { 106 | palette <- match.arg(palette) 107 | if (is_ggplot2_350()) { 108 | discrete_scale("fill", palette = pal_uchicago(palette, alpha), ...) 109 | } else { 110 | discrete_scale("fill", scale_name = "uchicago", palette = pal_uchicago(palette, alpha), ...) 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /R/discrete-ucscgb.R: -------------------------------------------------------------------------------- 1 | #' UCSC Genome Browser color palette 2 | #' 3 | #' Color palette from UCSC Genome Browser chromosome colors. 4 | #' 5 | #' @param palette Palette type. 6 | #' Currently there is one available option: `"default"` 7 | #' (26-color palette). 8 | #' @param alpha Transparency level, a real number in (0, 1]. 9 | #' See `alpha` in [grDevices::rgb()] for details. 10 | #' 11 | #' @export pal_ucscgb 12 | #' 13 | #' @importFrom grDevices col2rgb rgb 14 | #' @importFrom scales manual_pal 15 | #' 16 | #' @author Nan Xiao | \email{me@nanx.me} | 17 | #' 18 | #' @examples 19 | #' library("scales") 20 | #' show_col(pal_ucscgb("default")(26)) 21 | #' show_col(pal_ucscgb("default", alpha = 0.6)(26)) 22 | pal_ucscgb <- function(palette = c("default"), alpha = 1) { 23 | palette <- match.arg(palette) 24 | 25 | if (alpha > 1L || alpha <= 0L) stop("alpha must be in (0, 1]") 26 | 27 | raw_cols <- ggsci_db$"ucscgb"[[palette]] 28 | raw_cols_rgb <- col2rgb(raw_cols) 29 | alpha_cols <- rgb( 30 | raw_cols_rgb[1L, ], raw_cols_rgb[2L, ], raw_cols_rgb[3L, ], 31 | alpha = alpha * 255L, names = names(raw_cols), 32 | maxColorValue = 255L 33 | ) 34 | 35 | manual_pal(unname(alpha_cols)) 36 | } 37 | 38 | #' UCSC Genome Browser color scales 39 | #' 40 | #' See [pal_ucscgb()] for details. 41 | #' 42 | #' @inheritParams pal_ucscgb 43 | #' @param ... Additional parameters for [ggplot2::discrete_scale()]. 44 | #' 45 | #' @export scale_color_ucscgb 46 | #' 47 | #' @importFrom ggplot2 discrete_scale 48 | #' 49 | #' @author Nan Xiao | \email{me@nanx.me} | 50 | #' 51 | #' @rdname scale_ucscgb 52 | #' 53 | #' @examples 54 | #' library("ggplot2") 55 | #' data("diamonds") 56 | #' 57 | #' ggplot( 58 | #' subset(diamonds, carat >= 2.2), 59 | #' aes(x = table, y = price, colour = cut) 60 | #' ) + 61 | #' geom_point(alpha = 0.7) + 62 | #' geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 63 | #' theme_bw() + 64 | #' scale_color_ucscgb() 65 | #' 66 | #' ggplot( 67 | #' subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 68 | #' aes(x = depth, fill = cut) 69 | #' ) + 70 | #' geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 71 | #' theme_bw() + 72 | #' scale_fill_ucscgb() 73 | scale_color_ucscgb <- function(palette = c("default"), alpha = 1, ...) { 74 | palette <- match.arg(palette) 75 | if (is_ggplot2_350()) { 76 | discrete_scale("colour", palette = pal_ucscgb(palette, alpha), ...) 77 | } else { 78 | discrete_scale("colour", scale_name = "ucscgb", palette = pal_ucscgb(palette, alpha), ...) 79 | } 80 | } 81 | 82 | #' @export scale_colour_ucscgb 83 | #' @rdname scale_ucscgb 84 | scale_colour_ucscgb <- scale_color_ucscgb 85 | 86 | #' @export scale_fill_ucscgb 87 | #' @importFrom ggplot2 discrete_scale 88 | #' @rdname scale_ucscgb 89 | scale_fill_ucscgb <- function(palette = c("default"), alpha = 1, ...) { 90 | palette <- match.arg(palette) 91 | if (is_ggplot2_350()) { 92 | discrete_scale("fill", palette = pal_ucscgb(palette, alpha), ...) 93 | } else { 94 | discrete_scale("fill", scale_name = "ucscgb", palette = pal_ucscgb(palette, alpha), ...) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /R/ggsci-package.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | "_PACKAGE" 3 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | # These functions: 2 | # - `is_installed()` 3 | # - `get_package_version()` 4 | # - `system_file_cached()` 5 | # were sourced from the shiny package version 1.8.0, available at 6 | # . 7 | # 8 | # For the original version of these functions, please see: 9 | # . 10 | # 11 | # The shiny package is licensed under the GNU General Public License version 3. 12 | # For more details on the license, see 13 | # . 14 | 15 | is_installed <- function(pkg, version = NULL) { 16 | installed <- isNamespaceLoaded(pkg) || nzchar(system_file_cached(package = pkg)) 17 | 18 | if (is.null(version)) { 19 | return(installed) 20 | } 21 | 22 | if (!is.character(version) && !inherits(version, "numeric_version")) { 23 | # Avoid https://bugs.r-project.org/show_bug.cgi?id=18548 24 | alert <- if (identical(Sys.getenv("TESTTHAT"), "true")) stop else warning 25 | alert("`version` must be a character string or a `package_version` or `numeric_version` object.") 26 | 27 | version <- numeric_version(sprintf("%0.9g", version)) 28 | } 29 | 30 | installed && isTRUE(get_package_version(pkg) >= version) 31 | } 32 | 33 | get_package_version <- function(pkg) { 34 | # `utils::packageVersion()` can be slow, so first try the fast path of 35 | # checking if the package is already loaded. 36 | ns <- .getNamespace(pkg) 37 | if (is.null(ns)) { 38 | utils::packageVersion(pkg) 39 | } else { 40 | as.package_version(ns$.__NAMESPACE__.$spec[["version"]]) 41 | } 42 | } 43 | 44 | # A wrapper for `system.file()`, which caches the package path because 45 | # `system.file()` can be slow. If a package is not installed, the result won't 46 | # be cached. 47 | system_file_cached <- local({ 48 | pkg_dir_cache <- character() 49 | 50 | function(..., package = "base") { 51 | if (!is.null(names(list(...)))) { 52 | stop("All arguments other than `package` must be unnamed.") 53 | } 54 | 55 | not_cached <- is.na(match(package, names(pkg_dir_cache))) 56 | if (not_cached) { 57 | pkg_dir <- system.file(package = package) 58 | if (nzchar(pkg_dir)) { 59 | pkg_dir_cache[[package]] <<- pkg_dir 60 | } 61 | } else { 62 | pkg_dir <- pkg_dir_cache[[package]] 63 | } 64 | 65 | file.path(pkg_dir, ...) 66 | } 67 | }) 68 | 69 | is_ggplot2_350 <- function() { 70 | is_installed("ggplot2", version = "3.5.0") 71 | } 72 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # ggsci 5 | 6 | 7 | 8 | [![R-CMD-check](https://github.com/nanxstats/ggsci/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nanxstats/ggsci/actions/workflows/R-CMD-check.yaml) 9 | [![CRAN 10 | Version](https://www.r-pkg.org/badges/version/ggsci)](https://cran.r-project.org/package=ggsci) 11 | [![Downloads from the RStudio CRAN 12 | mirror](https://cranlogs.r-pkg.org/badges/ggsci)](https://cran.r-project.org/package=ggsci) 13 | 14 | 15 | ggsci offers a collection of ggplot2 color palettes inspired by 16 | scientific journals, data visualization libraries, science fiction 17 | movies, and TV shows. 18 | 19 | ## Installation 20 | 21 | You can install ggsci from CRAN: 22 | 23 | ``` r 24 | install.packages("ggsci") 25 | ``` 26 | 27 | Or try the development version on GitHub: 28 | 29 | ``` r 30 | remotes::install_github("nanxstats/ggsci") 31 | ``` 32 | 33 | [Browse the vignette](https://nanx.me/ggsci/articles/ggsci.html) (or 34 | open with `vignette("ggsci")` in R) for a quick-start guide. 35 | 36 | ## Gallery 37 | 38 | ### NPG 39 | 40 | 41 | 42 | ### AAAS 43 | 44 | 45 | 46 | ### NEJM 47 | 48 | 49 | 50 | ### Lancet 51 | 52 | 53 | 54 | ### JAMA 55 | 56 | 57 | 58 | ### BMJ 59 | 60 | 61 | 62 | ### JCO 63 | 64 | 65 | 66 | ### UCSCGB 67 | 68 | 69 | 70 | ### D3 71 | 72 | 73 | 74 | ### Observable 75 | 76 | 77 | 78 | ### LocusZoom 79 | 80 | 81 | 82 | ### IGV 83 | 84 | 85 | 86 | ### COSMIC 87 | 88 | 89 | 90 | ### UChicago 91 | 92 | 93 | 94 | ### Star Trek 95 | 96 | 97 | 98 | ### Tron Legacy 99 | 100 | 101 | 102 | ### Futurama 103 | 104 | 105 | 106 | ### Rick and Morty 107 | 108 | 109 | 110 | ### The Simpsons 111 | 112 | 113 | 114 | ### Flat UI 115 | 116 | 117 | 118 | ### Frontiers 119 | 120 | 121 | 122 | ### GSEA 123 | 124 | 125 | 126 | ### Bootstrap 5 127 | 128 | 129 | 130 | ### Material Design 131 | 132 | 133 | 134 | ### Tailwind CSS 135 | 136 | 137 | 138 | ## Contribute 139 | 140 | To contribute to this project, please take a look at the [Contributing 141 | Guidelines](https://nanx.me/ggsci/CONTRIBUTING.html) first. Please note 142 | that the ggsci project is released with a [Contributor Code of 143 | Conduct](https://nanx.me/ggsci/CODE_OF_CONDUCT.html). By contributing to 144 | this project, you agree to abide by its terms. 145 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://nanx.me/ggsci/ 2 | 3 | template: 4 | bootstrap: 5 5 | bslib: 6 | preset: "bootstrap" 7 | 8 | reference: 9 | - title: "NPG" 10 | contents: 11 | - pal_npg 12 | - scale_color_npg 13 | - scale_colour_npg 14 | - scale_fill_npg 15 | - title: "AAAS" 16 | contents: 17 | - pal_aaas 18 | - scale_color_aaas 19 | - scale_colour_aaas 20 | - scale_fill_aaas 21 | - title: "NEJM" 22 | contents: 23 | - pal_nejm 24 | - scale_color_nejm 25 | - scale_colour_nejm 26 | - scale_fill_nejm 27 | - title: "Lancet" 28 | contents: 29 | - pal_lancet 30 | - scale_color_lancet 31 | - scale_colour_lancet 32 | - scale_fill_lancet 33 | - title: "JAMA" 34 | contents: 35 | - pal_jama 36 | - scale_color_jama 37 | - scale_colour_jama 38 | - scale_fill_jama 39 | - title: "BMJ" 40 | contents: 41 | - pal_bmj 42 | - scale_color_bmj 43 | - scale_colour_bmj 44 | - scale_fill_bmj 45 | - title: "JCO" 46 | contents: 47 | - pal_jco 48 | - scale_color_jco 49 | - scale_colour_jco 50 | - scale_fill_jco 51 | - title: "UCSCGB" 52 | contents: 53 | - pal_ucscgb 54 | - scale_color_ucscgb 55 | - scale_colour_ucscgb 56 | - scale_fill_ucscgb 57 | - title: "D3" 58 | contents: 59 | - pal_d3 60 | - scale_color_d3 61 | - scale_colour_d3 62 | - scale_fill_d3 63 | - title: "Observable" 64 | contents: 65 | - pal_observable 66 | - scale_color_observable 67 | - scale_colour_observable 68 | - scale_fill_observable 69 | - title: "LocusZoom" 70 | contents: 71 | - pal_locuszoom 72 | - scale_color_locuszoom 73 | - scale_colour_locuszoom 74 | - scale_fill_locuszoom 75 | - title: "IGV" 76 | contents: 77 | - pal_igv 78 | - scale_color_igv 79 | - scale_colour_igv 80 | - scale_fill_igv 81 | - title: "COSMIC" 82 | contents: 83 | - pal_cosmic 84 | - scale_color_cosmic 85 | - scale_colour_cosmic 86 | - scale_fill_cosmic 87 | - title: "UChicago" 88 | contents: 89 | - pal_uchicago 90 | - scale_color_uchicago 91 | - scale_colour_uchicago 92 | - scale_fill_uchicago 93 | - title: "Star Trek" 94 | contents: 95 | - pal_startrek 96 | - scale_color_startrek 97 | - scale_colour_startrek 98 | - scale_fill_startrek 99 | - title: "Tron Legacy" 100 | contents: 101 | - pal_tron 102 | - scale_color_tron 103 | - scale_colour_tron 104 | - scale_fill_tron 105 | - title: "Futurama" 106 | contents: 107 | - pal_futurama 108 | - scale_color_futurama 109 | - scale_colour_futurama 110 | - scale_fill_futurama 111 | - title: "Rick and Morty" 112 | contents: 113 | - pal_rickandmorty 114 | - scale_color_rickandmorty 115 | - scale_colour_rickandmorty 116 | - scale_fill_rickandmorty 117 | - title: "The Simpsons" 118 | contents: 119 | - pal_simpsons 120 | - scale_color_simpsons 121 | - scale_colour_simpsons 122 | - scale_fill_simpsons 123 | - title: "Flat UI" 124 | contents: 125 | - pal_flatui 126 | - scale_color_flatui 127 | - scale_colour_flatui 128 | - scale_fill_flatui 129 | - title: "Frontiers" 130 | contents: 131 | - pal_frontiers 132 | - scale_color_frontiers 133 | - scale_colour_frontiers 134 | - scale_fill_frontiers 135 | - title: "GSEA" 136 | contents: 137 | - rgb_gsea 138 | - pal_gsea 139 | - scale_color_gsea 140 | - scale_colour_gsea 141 | - scale_fill_gsea 142 | - title: "Bootstrap 5" 143 | contents: 144 | - rgb_bs5 145 | - pal_bs5 146 | - scale_color_bs5 147 | - scale_colour_bs5 148 | - scale_fill_bs5 149 | - title: "Material Design" 150 | contents: 151 | - rgb_material 152 | - pal_material 153 | - scale_color_material 154 | - scale_colour_material 155 | - scale_fill_material 156 | - title: "Tailwind CSS" 157 | contents: 158 | - rgb_tw3 159 | - pal_tw3 160 | - scale_color_tw3 161 | - scale_colour_tw3 162 | - scale_fill_tw3 163 | -------------------------------------------------------------------------------- /ggsci.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | StripTrailingWhitespace: Yes 16 | 17 | BuildType: Package 18 | PackageUseDevtools: Yes 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | PackageRoxygenize: rd,collate,namespace 21 | -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | AAAS 2 | BMJ 3 | Bioinformatics 4 | CMD 5 | Catalogue 6 | Circos 7 | ColorBrewer 8 | Fi 9 | Futurama 10 | GSEA 11 | GenePattern 12 | Getz 13 | Guttman 14 | Hanahan 15 | HeatMapImage 16 | IGV 17 | JAMA 18 | JCO 19 | LocusZoom 20 | Mesirov 21 | Morty 22 | NEJM 23 | NPG 24 | ORCID 25 | Pruim 26 | RStudio 27 | SSL 28 | Schwifty 29 | Thorvaldsdóttir 30 | Translational 31 | UCSC 32 | UCSCGB 33 | UChicago 34 | UI 35 | Winckler 36 | al 37 | et 38 | ggplot 39 | jhrcook 40 | js 41 | pandoc 42 | pngquant 43 | ragg 44 | viridis 45 | -------------------------------------------------------------------------------- /inst/logo/logo.R: -------------------------------------------------------------------------------- 1 | library("magick") 2 | library("showtext") 3 | 4 | font_add_google("Zilla Slab", "pf", regular.wt = 500) 5 | 6 | hexSticker::sticker( 7 | subplot = ~ plot.new(), s_x = 1, s_y = 1, s_width = 0.1, s_height = 0.1, 8 | package = "ggsci", p_x = 1, p_y = 1, p_size = 12, h_size = 1.2, p_family = "pf", 9 | p_color = "#F06060", h_fill = "#FFF9F2", h_color = "#F06060", 10 | dpi = 320, filename = "man/figures/logo.png" 11 | ) 12 | 13 | image_read("man/figures/logo.png") 14 | 15 | rstudioapi::restartSession() 16 | -------------------------------------------------------------------------------- /man/figures/README-ggsci-aaas-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-aaas-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-bmj-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-bmj-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-bs5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-bs5-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-cosmic-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-cosmic-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-cosmic-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-cosmic-2.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-cosmic-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-cosmic-3.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-d3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-d3-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-flatui-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-flatui-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-frontiers-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-frontiers-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-futurama-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-futurama-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-gsea-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-gsea-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-igv-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-igv-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-jama-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-jama-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-jco-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-jco-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-lancet-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-lancet-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-locuszoom-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-locuszoom-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-material-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-material-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-nejm-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-nejm-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-npg-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-npg-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-observable-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-observable-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-rickandmorty-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-rickandmorty-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-simpsons-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-simpsons-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-startrek-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-startrek-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-tron-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-tron-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-tw3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-tw3-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-uchicago-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-uchicago-1.png -------------------------------------------------------------------------------- /man/figures/README-ggsci-ucscgb-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/README-ggsci-ucscgb-1.png -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/man/figures/logo.png -------------------------------------------------------------------------------- /man/ggsci-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ggsci-package.R 3 | \docType{package} 4 | \name{ggsci-package} 5 | \alias{ggsci} 6 | \alias{ggsci-package} 7 | \title{ggsci: Scientific Journal and Sci-Fi Themed Color Palettes for 'ggplot2'} 8 | \description{ 9 | \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} 10 | 11 | A collection of 'ggplot2' color palettes inspired by plots in scientific journals, data visualization libraries, science fiction movies, and TV shows. 12 | } 13 | \seealso{ 14 | Useful links: 15 | \itemize{ 16 | \item \url{https://nanx.me/ggsci/} 17 | \item \url{https://github.com/nanxstats/ggsci} 18 | \item Report bugs at \url{https://github.com/nanxstats/ggsci/issues} 19 | } 20 | 21 | } 22 | \author{ 23 | \strong{Maintainer}: Nan Xiao \email{me@nanx.me} (\href{https://orcid.org/0000-0002-0250-5673}{ORCID}) 24 | 25 | Other contributors: 26 | \itemize{ 27 | \item Joshua Cook \email{joshuacook0023@gmail.com} [contributor] 28 | \item Clara Jégousse \email{cat3@hi.is} [contributor] 29 | \item Hui Chen \email{huichen@zju.edu.cn} [contributor] 30 | \item Miaozhu Li \email{miaozhu.li@duke.edu} [contributor] 31 | } 32 | 33 | } 34 | \keyword{internal} 35 | -------------------------------------------------------------------------------- /man/pal_aaas.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-aaas.R 3 | \name{pal_aaas} 4 | \alias{pal_aaas} 5 | \title{AAAS journal color palettes} 6 | \usage{ 7 | pal_aaas(palette = c("default"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (10-color palette inspired by \emph{Science}).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by plots in journals published by 19 | American Association for the Advancement of Science (AAAS), 20 | such as \emph{Science} and \emph{Science Translational Medicine}. 21 | } 22 | \examples{ 23 | library("scales") 24 | show_col(pal_aaas("default")(10)) 25 | show_col(pal_aaas("default", alpha = 0.6)(10)) 26 | } 27 | \author{ 28 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 29 | } 30 | -------------------------------------------------------------------------------- /man/pal_bmj.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-bmj.R 3 | \name{pal_bmj} 4 | \alias{pal_bmj} 5 | \title{BMJ color palettes} 6 | \usage{ 7 | pal_bmj(palette = c("default"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (9-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palette from the BMJ living style guide. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_bmj("default")(9)) 23 | show_col(pal_bmj("default", alpha = 0.6)(9)) 24 | } 25 | \references{ 26 | \url{https://technology.bmj.com/living-style-guide/colour.html} 27 | } 28 | \author{ 29 | Hui Chen | \email{huichen@zju.edu.cn} 30 | } 31 | -------------------------------------------------------------------------------- /man/pal_bs5.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-bs5.R 3 | \name{pal_bs5} 4 | \alias{pal_bs5} 5 | \title{Bootstrap 5 color palettes} 6 | \usage{ 7 | pal_bs5( 8 | palette = c("blue", "indigo", "purple", "pink", "red", "orange", "yellow", "green", 9 | "teal", "cyan", "gray"), 10 | n = 10, 11 | alpha = 1, 12 | reverse = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. There are 11 available options: 17 | \itemize{ 18 | \item \code{"blue"} 19 | \item \code{"indigo"} 20 | \item \code{"purple"} 21 | \item \code{"pink"} 22 | \item \code{"red"} 23 | \item \code{"orange"} 24 | \item \code{"yellow"} 25 | \item \code{"green"} 26 | \item \code{"teal"} 27 | \item \code{"cyan"} 28 | \item \code{"gray"} 29 | }} 30 | 31 | \item{n}{Number of individual colors to be generated.} 32 | 33 | \item{alpha}{Transparency level, a real number in (0, 1]. 34 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 35 | 36 | \item{reverse}{Logical. Should the order of the colors be reversed?} 37 | } 38 | \description{ 39 | Bootstrap 5 color palettes. 40 | } 41 | \examples{ 42 | library("scales") 43 | show_col(pal_bs5("indigo")(10)) 44 | show_col(pal_bs5("indigo", n = 30, alpha = 0.6, reverse = TRUE)(30)) 45 | } 46 | \author{ 47 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 48 | } 49 | -------------------------------------------------------------------------------- /man/pal_cosmic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-cosmic.R 3 | \name{pal_cosmic} 4 | \alias{pal_cosmic} 5 | \title{COSMIC color palettes} 6 | \usage{ 7 | pal_cosmic( 8 | palette = c("hallmarks_light", "hallmarks_dark", "signature_substitutions"), 9 | alpha = 1 10 | ) 11 | } 12 | \arguments{ 13 | \item{palette}{Palette type. Currently there are three available options: 14 | \itemize{ 15 | \item \code{"signature_substitutions"} (6-color palette). 16 | \item \code{"hallmarks_light"} (10-color palette). 17 | \item \code{"hallmarks_dark"} (10-color palette). 18 | } 19 | 20 | The \code{"hallmarks_light"} option is from 21 | \href{https://pubmed.ncbi.nlm.nih.gov/21376230/}{Hanahan and Weinberg (2011)}.} 22 | 23 | \item{alpha}{Transparency level, a real number in (0, 1]. 24 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 25 | } 26 | \description{ 27 | Color palettes inspired by the colors used in projects from the 28 | \href{https://cancer.sanger.ac.uk/cosmic}{Catalogue Of Somatic Mutations in Cancers (COSMIC)}. 29 | } 30 | \examples{ 31 | library("scales") 32 | show_col(pal_cosmic("hallmarks_light")(10)) 33 | show_col(pal_cosmic("hallmarks_light", alpha = 0.6)(10)) 34 | show_col(pal_cosmic("hallmarks_dark")(10)) 35 | show_col(pal_cosmic("hallmarks_dark", alpha = 0.6)(10)) 36 | show_col(pal_cosmic("signature_substitutions")(6)) 37 | show_col(pal_cosmic("signature_substitutions", alpha = 0.6)(6)) 38 | } 39 | \author{ 40 | Joshua H. Cook | \email{joshuacook0023@gmail.com} | 41 | \href{https://github.com/jhrcook}{@jhrcook} 42 | } 43 | -------------------------------------------------------------------------------- /man/pal_d3.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-d3.R 3 | \name{pal_d3} 4 | \alias{pal_d3} 5 | \title{D3.js color palettes} 6 | \usage{ 7 | pal_d3( 8 | palette = c("category10", "category20", "category20b", "category20c"), 9 | alpha = 1 10 | ) 11 | } 12 | \arguments{ 13 | \item{palette}{Palette type. There are four available options: 14 | \itemize{ 15 | \item \code{"category10"} (10-color palette). 16 | \item \code{"category20"} (20-color palette). 17 | \item \code{"category20b"} (20-color palette). 18 | \item \code{"category20c"} (20-color palette). 19 | }} 20 | 21 | \item{alpha}{Transparency level, a real number in (0, 1]. 22 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 23 | } 24 | \description{ 25 | Color palettes based on the colors used by D3.js. 26 | } 27 | \examples{ 28 | library("scales") 29 | show_col(pal_d3("category10")(10)) 30 | show_col(pal_d3("category20")(20)) 31 | show_col(pal_d3("category20b")(20)) 32 | show_col(pal_d3("category20c")(20)) 33 | } 34 | \references{ 35 | \url{https://github.com/d3/d3-3.x-api-reference/blob/master/Ordinal-Scales.md} 36 | } 37 | \author{ 38 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 39 | } 40 | -------------------------------------------------------------------------------- /man/pal_flatui.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-flatui.R 3 | \name{pal_flatui} 4 | \alias{pal_flatui} 5 | \title{Flat UI color palettes} 6 | \usage{ 7 | pal_flatui(palette = c("default", "flattastic", "aussie"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. Currently there are three available options: 11 | \itemize{ 12 | \item \code{"default"} (10-color palette). 13 | \item \code{"flattastic"} (12-color palette). 14 | \item \code{"aussie"} (10-color palette). 15 | }} 16 | 17 | \item{alpha}{Transparency level, a real number in (0, 1]. 18 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 19 | } 20 | \description{ 21 | Color palettes inspired by the Flat UI colors. 22 | } 23 | \examples{ 24 | library("scales") 25 | show_col(pal_flatui("default")(10)) 26 | show_col(pal_flatui("flattastic")(12)) 27 | show_col(pal_flatui("aussie")(10)) 28 | show_col(pal_flatui("aussie", alpha = 0.6)(10)) 29 | } 30 | \author{ 31 | Clara Jégousse | \email{cat3@hi.is} 32 | } 33 | -------------------------------------------------------------------------------- /man/pal_frontiers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-frontiers.R 3 | \name{pal_frontiers} 4 | \alias{pal_frontiers} 5 | \title{Frontiers journal color palettes} 6 | \usage{ 7 | pal_frontiers(palette = c("default"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (10-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by the colors used in \emph{Frontiers} journals. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_frontiers("default")(7)) 23 | show_col(pal_frontiers("default", alpha = 0.6)(7)) 24 | } 25 | \author{ 26 | Clara Jégousse | \email{cat3@hi.is} 27 | } 28 | -------------------------------------------------------------------------------- /man/pal_futurama.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-futurama.R 3 | \name{pal_futurama} 4 | \alias{pal_futurama} 5 | \title{Futurama color palettes} 6 | \usage{ 7 | pal_futurama(palette = c("planetexpress"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"planetexpress"} 12 | (12-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by the colors used in \emph{Futurama}. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_futurama("planetexpress")(12)) 23 | show_col(pal_futurama("planetexpress", alpha = 0.6)(12)) 24 | } 25 | \author{ 26 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 27 | } 28 | -------------------------------------------------------------------------------- /man/pal_gsea.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-gsea.R 3 | \name{pal_gsea} 4 | \alias{pal_gsea} 5 | \title{The GSEA GenePattern color palettes} 6 | \usage{ 7 | pal_gsea(palette = c("default"), n = 12, alpha = 1, reverse = FALSE) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (continuous palette with 12 base colors).} 13 | 14 | \item{n}{Number of individual colors to be generated.} 15 | 16 | \item{alpha}{Transparency level, a real number in (0, 1]. 17 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 18 | 19 | \item{reverse}{Logical. Should the order of the colors be reversed?} 20 | } 21 | \description{ 22 | Color palette inspired by the colors used in the 23 | heatmaps plotted by GSEA GenePattern. 24 | } 25 | \examples{ 26 | library("scales") 27 | show_col(pal_gsea("default")(12)) 28 | show_col(pal_gsea("default", n = 30, alpha = 0.6, reverse = TRUE)(30)) 29 | } 30 | \author{ 31 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 32 | } 33 | -------------------------------------------------------------------------------- /man/pal_igv.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-igv.R 3 | \name{pal_igv} 4 | \alias{pal_igv} 5 | \title{Integrative Genomics Viewer (IGV) color palettes} 6 | \usage{ 7 | pal_igv(palette = c("default", "alternating"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | There are two available options: 12 | \itemize{ 13 | \item \code{"default"} (51-color palette). 14 | \item \code{"alternating"} (2-color palette). 15 | }} 16 | 17 | \item{alpha}{Transparency level, a real number in (0, 1]. 18 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 19 | } 20 | \description{ 21 | Color palettes based on the colors used by 22 | Integrative Genomics Viewer (IGV). 23 | } 24 | \examples{ 25 | library("scales") 26 | show_col(pal_igv("default")(51)) 27 | show_col(pal_igv("alternating")(2)) 28 | } 29 | \references{ 30 | James T. Robinson, Helga Thorvaldsdóttir, Wendy Winckler, 31 | Mitchell Guttman, Eric S. Lander, Gad Getz, Jill P. Mesirov. 32 | Integrative Genomics Viewer. \emph{Nature Biotechnology} 29, 24--26 (2011). 33 | } 34 | \author{ 35 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 36 | } 37 | -------------------------------------------------------------------------------- /man/pal_jama.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-jama.R 3 | \name{pal_jama} 4 | \alias{pal_jama} 5 | \title{Journal of the American Medical Association color palettes} 6 | \usage{ 7 | pal_jama(palette = c("default"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (7-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palette inspired by plots in 19 | \emph{The Journal of the American Medical Association}. 20 | } 21 | \examples{ 22 | library("scales") 23 | show_col(pal_jama("default")(7)) 24 | show_col(pal_jama("default", alpha = 0.6)(7)) 25 | } 26 | \author{ 27 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 28 | } 29 | -------------------------------------------------------------------------------- /man/pal_jco.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-jco.R 3 | \name{pal_jco} 4 | \alias{pal_jco} 5 | \title{Journal of Clinical Oncology color palettes} 6 | \usage{ 7 | pal_jco(palette = c("default"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (10-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palette inspired by plots in \emph{Journal of Clinical Oncology}. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_jco("default")(10)) 23 | show_col(pal_jco("default", alpha = 0.6)(10)) 24 | } 25 | \author{ 26 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 27 | } 28 | -------------------------------------------------------------------------------- /man/pal_lancet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-lancet.R 3 | \name{pal_lancet} 4 | \alias{pal_lancet} 5 | \title{Lancet journal color palettes} 6 | \usage{ 7 | pal_lancet(palette = c("lanonc"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"lanonc"} 12 | (9-color palette inspired by \emph{Lancet Oncology}).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by plots in Lancet journals, 19 | such as \emph{Lancet Oncology}. 20 | } 21 | \examples{ 22 | library("scales") 23 | show_col(pal_lancet("lanonc")(9)) 24 | show_col(pal_lancet("lanonc", alpha = 0.6)(9)) 25 | } 26 | \author{ 27 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 28 | } 29 | -------------------------------------------------------------------------------- /man/pal_locuszoom.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-locuszoom.R 3 | \name{pal_locuszoom} 4 | \alias{pal_locuszoom} 5 | \title{LocusZoom color palette} 6 | \usage{ 7 | pal_locuszoom(palette = c("default"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (7-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes based on the colors used by LocusZoom. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_locuszoom("default")(7)) 23 | show_col(pal_locuszoom("default", alpha = 0.6)(7)) 24 | } 25 | \references{ 26 | Pruim, Randall J., et al. (2010). LocusZoom: regional visualization of 27 | genome-wide association scan results. \emph{Bioinformatics}, 28 | 26(18), 2336--2337. 29 | } 30 | \author{ 31 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 32 | } 33 | -------------------------------------------------------------------------------- /man/pal_material.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-material.R 3 | \name{pal_material} 4 | \alias{pal_material} 5 | \title{Material Design color palettes} 6 | \usage{ 7 | pal_material( 8 | palette = c("red", "pink", "purple", "deep-purple", "indigo", "blue", "light-blue", 9 | "cyan", "teal", "green", "light-green", "lime", "yellow", "amber", "orange", 10 | "deep-orange", "brown", "grey", "blue-grey"), 11 | n = 10, 12 | alpha = 1, 13 | reverse = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{palette}{Palette type. There are 19 available options: 18 | \itemize{ 19 | \item \code{"red"} 20 | \item \code{"pink"} 21 | \item \code{"purple"} 22 | \item \code{"deep-purple"} 23 | \item \code{"indigo"} 24 | \item \code{"blue"} 25 | \item \code{"light-blue"} 26 | \item \code{"cyan"} 27 | \item \code{"teal"} 28 | \item \code{"green"} 29 | \item \code{"light-green"} 30 | \item \code{"lime"} 31 | \item \code{"yellow"} 32 | \item \code{"amber"} 33 | \item \code{"orange"} 34 | \item \code{"deep-orange"} 35 | \item \code{"brown"} 36 | \item \code{"grey"} 37 | \item \code{"blue-grey"} 38 | }} 39 | 40 | \item{n}{Number of individual colors to be generated.} 41 | 42 | \item{alpha}{Transparency level, a real number in (0, 1]. 43 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 44 | 45 | \item{reverse}{Logical. Should the order of the colors be reversed?} 46 | } 47 | \description{ 48 | Material Design 2 color palettes. 49 | } 50 | \examples{ 51 | library("scales") 52 | show_col(pal_material("indigo")(10)) 53 | show_col(pal_material("indigo", n = 30, alpha = 0.6, reverse = TRUE)(30)) 54 | } 55 | \author{ 56 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 57 | } 58 | -------------------------------------------------------------------------------- /man/pal_nejm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-nejm.R 3 | \name{pal_nejm} 4 | \alias{pal_nejm} 5 | \title{NEJM color palettes} 6 | \usage{ 7 | pal_nejm(palette = c("default"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (8-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palette inspired by plots in 19 | \emph{The New England Journal of Medicine}. 20 | } 21 | \examples{ 22 | library("scales") 23 | show_col(pal_nejm("default")(8)) 24 | show_col(pal_nejm("default", alpha = 0.6)(8)) 25 | } 26 | \author{ 27 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 28 | } 29 | -------------------------------------------------------------------------------- /man/pal_npg.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-npg.R 3 | \name{pal_npg} 4 | \alias{pal_npg} 5 | \title{NPG journal color palettes} 6 | \usage{ 7 | pal_npg(palette = c("nrc"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"nrc"} 12 | (10-color palette inspired by \emph{Nature Reviews Cancer}).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by plots in journals published by 19 | Nature Publishing Group, such as \emph{Nature Reviews Cancer}. 20 | } 21 | \examples{ 22 | library("scales") 23 | show_col(pal_npg("nrc")(10)) 24 | show_col(pal_npg("nrc", alpha = 0.6)(10)) 25 | } 26 | \author{ 27 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 28 | } 29 | -------------------------------------------------------------------------------- /man/pal_observable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-observable.R 3 | \name{pal_observable} 4 | \alias{pal_observable} 5 | \title{Observable 10 color palette} 6 | \usage{ 7 | pal_observable(palette = c("observable10"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"observable10"} 12 | (10-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | The Observable 10 palette. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_observable("observable10")(10)) 23 | show_col(pal_observable("observable10", alpha = 0.6)(10)) 24 | } 25 | \references{ 26 | Pettiross J (2023). "Crafting data colors and staying on brand." 27 | \emph{Observable blog}. \url{https://observablehq.com/blog/crafting-data-colors} 28 | } 29 | \author{ 30 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 31 | } 32 | -------------------------------------------------------------------------------- /man/pal_rickandmorty.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-rickandmorty.R 3 | \name{pal_rickandmorty} 4 | \alias{pal_rickandmorty} 5 | \title{Rick and Morty color palettes} 6 | \usage{ 7 | pal_rickandmorty(palette = c("schwifty"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"schwifty"} 12 | (12-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by the colors used in \emph{Rick and Morty}. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_rickandmorty("schwifty")(12)) 23 | show_col(pal_rickandmorty("schwifty", alpha = 0.6)(12)) 24 | } 25 | \author{ 26 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 27 | } 28 | -------------------------------------------------------------------------------- /man/pal_simpsons.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-simpsons.R 3 | \name{pal_simpsons} 4 | \alias{pal_simpsons} 5 | \title{The Simpsons color palettes} 6 | \usage{ 7 | pal_simpsons(palette = c("springfield"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"springfield"} 12 | (16-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by the colors used in \emph{The Simpsons}. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_simpsons("springfield")(16)) 23 | show_col(pal_simpsons("springfield", alpha = 0.6)(16)) 24 | } 25 | \author{ 26 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 27 | } 28 | -------------------------------------------------------------------------------- /man/pal_startrek.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-startrek.R 3 | \name{pal_startrek} 4 | \alias{pal_startrek} 5 | \title{Star Trek color palettes} 6 | \usage{ 7 | pal_startrek(palette = c("uniform"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"uniform"} 12 | (7-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by the colors used in \emph{Star Trek}. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_startrek("uniform")(7)) 23 | show_col(pal_startrek("uniform", alpha = 0.6)(7)) 24 | } 25 | \author{ 26 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 27 | } 28 | -------------------------------------------------------------------------------- /man/pal_tron.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-tron.R 3 | \name{pal_tron} 4 | \alias{pal_tron} 5 | \title{Tron Legacy color palettes} 6 | \usage{ 7 | pal_tron(palette = c("legacy"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"legacy"} 12 | (7-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palettes inspired by the colors used in \emph{Tron Legacy}. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_tron("legacy")(7)) 23 | show_col(pal_tron("legacy", alpha = 0.6)(7)) 24 | } 25 | \author{ 26 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 27 | } 28 | -------------------------------------------------------------------------------- /man/pal_tw3.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-tw3.R 3 | \name{pal_tw3} 4 | \alias{pal_tw3} 5 | \title{Tailwind CSS color palettes} 6 | \usage{ 7 | pal_tw3( 8 | palette = c("slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 9 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", 10 | "violet", "purple", "fuchsia", "pink", "rose"), 11 | n = 10, 12 | alpha = 1, 13 | reverse = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{palette}{Palette type. There are 22 available options: 18 | \itemize{ 19 | \item \code{"slate"} 20 | \item \code{"gray"} 21 | \item \code{"zinc"} 22 | \item \code{"neutral"} 23 | \item \code{"stone"} 24 | \item \code{"red"} 25 | \item \code{"orange"} 26 | \item \code{"amber"} 27 | \item \code{"yellow"} 28 | \item \code{"lime"} 29 | \item \code{"green"} 30 | \item \code{"emerald"} 31 | \item \code{"teal"} 32 | \item \code{"cyan"} 33 | \item \code{"sky"} 34 | \item \code{"blue"} 35 | \item \code{"indigo"} 36 | \item \code{"violet"} 37 | \item \code{"purple"} 38 | \item \code{"fuchsia"} 39 | \item \code{"pink"} 40 | \item \code{"rose"} 41 | }} 42 | 43 | \item{n}{Number of individual colors to be generated.} 44 | 45 | \item{alpha}{Transparency level, a real number in (0, 1]. 46 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 47 | 48 | \item{reverse}{Logical. Should the order of the colors be reversed?} 49 | } 50 | \description{ 51 | Tailwind CSS color palettes. 52 | } 53 | \examples{ 54 | library("scales") 55 | show_col(pal_tw3("rose")(10)) 56 | show_col(pal_tw3("rose", n = 30, alpha = 0.6, reverse = TRUE)(30)) 57 | } 58 | \author{ 59 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 60 | } 61 | -------------------------------------------------------------------------------- /man/pal_uchicago.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-uchicago.R 3 | \name{pal_uchicago} 4 | \alias{pal_uchicago} 5 | \title{The University of Chicago color palettes} 6 | \usage{ 7 | pal_uchicago(palette = c("default", "light", "dark"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | There are three available options: 12 | \itemize{ 13 | \item \code{"default"} (9-color palette); 14 | \item \code{"light"} (9-color light palette); 15 | \item \code{"dark"} (9-color dark palette). 16 | }} 17 | 18 | \item{alpha}{Transparency level, a real number in (0, 1]. 19 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 20 | } 21 | \description{ 22 | Color palettes based on the colors used by the University of Chicago. 23 | } 24 | \examples{ 25 | library("scales") 26 | show_col(pal_uchicago("default")(9)) 27 | show_col(pal_uchicago("light")(9)) 28 | show_col(pal_uchicago("dark")(9)) 29 | } 30 | \references{ 31 | \url{https://news.uchicago.edu/sites/default/files/attachments/_uchicago.identity.guidelines.pdf} 32 | } 33 | \author{ 34 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 35 | } 36 | -------------------------------------------------------------------------------- /man/pal_ucscgb.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-ucscgb.R 3 | \name{pal_ucscgb} 4 | \alias{pal_ucscgb} 5 | \title{UCSC Genome Browser color palette} 6 | \usage{ 7 | pal_ucscgb(palette = c("default"), alpha = 1) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (26-color palette).} 13 | 14 | \item{alpha}{Transparency level, a real number in (0, 1]. 15 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 16 | } 17 | \description{ 18 | Color palette from UCSC Genome Browser chromosome colors. 19 | } 20 | \examples{ 21 | library("scales") 22 | show_col(pal_ucscgb("default")(26)) 23 | show_col(pal_ucscgb("default", alpha = 0.6)(26)) 24 | } 25 | \author{ 26 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 27 | } 28 | -------------------------------------------------------------------------------- /man/rgb_bs5.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-bs5.R 3 | \name{rgb_bs5} 4 | \alias{rgb_bs5} 5 | \title{Bootstrap 5 color palettes} 6 | \usage{ 7 | rgb_bs5( 8 | palette = c("blue", "indigo", "purple", "pink", "red", "orange", "yellow", "green", 9 | "teal", "cyan", "gray"), 10 | n = 10, 11 | alpha = 1, 12 | reverse = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. There are 11 available options: 17 | \itemize{ 18 | \item \code{"blue"} 19 | \item \code{"indigo"} 20 | \item \code{"purple"} 21 | \item \code{"pink"} 22 | \item \code{"red"} 23 | \item \code{"orange"} 24 | \item \code{"yellow"} 25 | \item \code{"green"} 26 | \item \code{"teal"} 27 | \item \code{"cyan"} 28 | \item \code{"gray"} 29 | }} 30 | 31 | \item{n}{Number of individual colors to be generated.} 32 | 33 | \item{alpha}{Transparency level, a real number in (0, 1]. 34 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 35 | 36 | \item{reverse}{Logical. Should the order of the colors be reversed?} 37 | } 38 | \description{ 39 | Bootstrap 5 color palettes. 40 | } 41 | \examples{ 42 | library("scales") 43 | show_col(pal_bs5("indigo")(10)) 44 | show_col(pal_bs5("indigo", n = 30, alpha = 0.6, reverse = TRUE)(30)) 45 | } 46 | \references{ 47 | \url{https://getbootstrap.com/docs/5.3/customize/color/#all-colors} 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/rgb_gsea.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-gsea.R 3 | \name{rgb_gsea} 4 | \alias{rgb_gsea} 5 | \title{The GSEA GenePattern color palettes} 6 | \usage{ 7 | rgb_gsea(palette = c("default"), n = 12, alpha = 1, reverse = FALSE) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette type. 11 | Currently there is one available option: \code{"default"} 12 | (continuous palette with 12 base colors).} 13 | 14 | \item{n}{Number of individual colors to be generated.} 15 | 16 | \item{alpha}{Transparency level, a real number in (0, 1]. 17 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 18 | 19 | \item{reverse}{Logical. Should the order of the colors be reversed?} 20 | } 21 | \description{ 22 | Color palette inspired by the colors used in the 23 | heatmaps plotted by GSEA GenePattern. 24 | } 25 | \note{ 26 | The 12 base colors used in this palette are derived from the 27 | \href{https://modulerepository.genepattern.org/gpModuleRepository/download/prod/module/?file=/HeatMapImage/broad.mit.edu:cancer.software.genepattern.module.analysis/00032/6/HeatMapImage.pdf}{HeatMapImage documentation}. 28 | } 29 | \examples{ 30 | library("scales") 31 | show_col(pal_gsea("default")(12)) 32 | show_col(pal_gsea("default", n = 30, alpha = 0.6, reverse = TRUE)(30)) 33 | } 34 | \author{ 35 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 36 | } 37 | -------------------------------------------------------------------------------- /man/rgb_material.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-material.R 3 | \name{rgb_material} 4 | \alias{rgb_material} 5 | \title{Material Design color palettes} 6 | \usage{ 7 | rgb_material( 8 | palette = c("red", "pink", "purple", "deep-purple", "indigo", "blue", "light-blue", 9 | "cyan", "teal", "green", "light-green", "lime", "yellow", "amber", "orange", 10 | "deep-orange", "brown", "grey", "blue-grey"), 11 | n = 10, 12 | alpha = 1, 13 | reverse = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{palette}{Palette type. There are 19 available options: 18 | \itemize{ 19 | \item \code{"red"} 20 | \item \code{"pink"} 21 | \item \code{"purple"} 22 | \item \code{"deep-purple"} 23 | \item \code{"indigo"} 24 | \item \code{"blue"} 25 | \item \code{"light-blue"} 26 | \item \code{"cyan"} 27 | \item \code{"teal"} 28 | \item \code{"green"} 29 | \item \code{"light-green"} 30 | \item \code{"lime"} 31 | \item \code{"yellow"} 32 | \item \code{"amber"} 33 | \item \code{"orange"} 34 | \item \code{"deep-orange"} 35 | \item \code{"brown"} 36 | \item \code{"grey"} 37 | \item \code{"blue-grey"} 38 | }} 39 | 40 | \item{n}{Number of individual colors to be generated.} 41 | 42 | \item{alpha}{Transparency level, a real number in (0, 1]. 43 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 44 | 45 | \item{reverse}{Logical. Should the order of the colors be reversed?} 46 | } 47 | \description{ 48 | Material Design 2 color palettes. 49 | } 50 | \examples{ 51 | library("scales") 52 | show_col(pal_material("indigo")(10)) 53 | show_col(pal_material("indigo", n = 30, alpha = 0.6, reverse = TRUE)(30)) 54 | } 55 | \references{ 56 | \url{https://m2.material.io/design/color/the-color-system.html} 57 | } 58 | \author{ 59 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 60 | } 61 | -------------------------------------------------------------------------------- /man/rgb_tw3.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-tw3.R 3 | \name{rgb_tw3} 4 | \alias{rgb_tw3} 5 | \title{Tailwind CSS color palettes} 6 | \usage{ 7 | rgb_tw3( 8 | palette = c("slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 9 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", 10 | "violet", "purple", "fuchsia", "pink", "rose"), 11 | n = 10, 12 | alpha = 1, 13 | reverse = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{palette}{Palette type. There are 22 available options: 18 | \itemize{ 19 | \item \code{"slate"} 20 | \item \code{"gray"} 21 | \item \code{"zinc"} 22 | \item \code{"neutral"} 23 | \item \code{"stone"} 24 | \item \code{"red"} 25 | \item \code{"orange"} 26 | \item \code{"amber"} 27 | \item \code{"yellow"} 28 | \item \code{"lime"} 29 | \item \code{"green"} 30 | \item \code{"emerald"} 31 | \item \code{"teal"} 32 | \item \code{"cyan"} 33 | \item \code{"sky"} 34 | \item \code{"blue"} 35 | \item \code{"indigo"} 36 | \item \code{"violet"} 37 | \item \code{"purple"} 38 | \item \code{"fuchsia"} 39 | \item \code{"pink"} 40 | \item \code{"rose"} 41 | }} 42 | 43 | \item{n}{Number of individual colors to be generated.} 44 | 45 | \item{alpha}{Transparency level, a real number in (0, 1]. 46 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 47 | 48 | \item{reverse}{Logical. Should the order of the colors be reversed?} 49 | } 50 | \description{ 51 | Tailwind CSS color palettes. 52 | } 53 | \examples{ 54 | library("scales") 55 | show_col(pal_tw3("rose")(10)) 56 | show_col(pal_tw3("rose", n = 30, alpha = 0.6, reverse = TRUE)(30)) 57 | } 58 | \references{ 59 | \url{https://tailwindcss.com/docs/customizing-colors} 60 | } 61 | \author{ 62 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 63 | } 64 | -------------------------------------------------------------------------------- /man/scale_aaas.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-aaas.R 3 | \name{scale_color_aaas} 4 | \alias{scale_color_aaas} 5 | \alias{scale_colour_aaas} 6 | \alias{scale_fill_aaas} 7 | \title{AAAS journal color scales} 8 | \usage{ 9 | scale_color_aaas(palette = c("default"), alpha = 1, ...) 10 | 11 | scale_colour_aaas(palette = c("default"), alpha = 1, ...) 12 | 13 | scale_fill_aaas(palette = c("default"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (10-color palette inspired by \emph{Science}).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_aaas]{pal_aaas()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_aaas() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_aaas() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_bmj.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-bmj.R 3 | \name{scale_color_bmj} 4 | \alias{scale_color_bmj} 5 | \alias{scale_colour_bmj} 6 | \alias{scale_fill_bmj} 7 | \title{BMJ color scales} 8 | \usage{ 9 | scale_color_bmj(palette = c("default"), alpha = 1, ...) 10 | 11 | scale_colour_bmj(palette = c("default"), alpha = 1, ...) 12 | 13 | scale_fill_bmj(palette = c("default"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (9-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_bmj]{pal_bmj()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_bmj() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_bmj() 48 | } 49 | \references{ 50 | \url{https://technology.bmj.com/living-style-guide/colour.html} 51 | } 52 | \author{ 53 | Hui Chen | \email{huichen@zju.edu.cn} 54 | } 55 | -------------------------------------------------------------------------------- /man/scale_bs5.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-bs5.R 3 | \name{scale_color_bs5} 4 | \alias{scale_color_bs5} 5 | \alias{scale_colour_bs5} 6 | \alias{scale_fill_bs5} 7 | \title{Bootstrap 5 color scales} 8 | \usage{ 9 | scale_color_bs5( 10 | palette = c("blue", "indigo", "purple", "pink", "red", "orange", "yellow", "green", 11 | "teal", "cyan", "gray"), 12 | alpha = 1, 13 | reverse = FALSE, 14 | ... 15 | ) 16 | 17 | scale_colour_bs5( 18 | palette = c("blue", "indigo", "purple", "pink", "red", "orange", "yellow", "green", 19 | "teal", "cyan", "gray"), 20 | alpha = 1, 21 | reverse = FALSE, 22 | ... 23 | ) 24 | 25 | scale_fill_bs5( 26 | palette = c("blue", "indigo", "purple", "pink", "red", "orange", "yellow", "green", 27 | "teal", "cyan", "gray"), 28 | alpha = 1, 29 | reverse = FALSE, 30 | ... 31 | ) 32 | } 33 | \arguments{ 34 | \item{palette}{Palette type. There are 11 available options: 35 | \itemize{ 36 | \item \code{"blue"} 37 | \item \code{"indigo"} 38 | \item \code{"purple"} 39 | \item \code{"pink"} 40 | \item \code{"red"} 41 | \item \code{"orange"} 42 | \item \code{"yellow"} 43 | \item \code{"green"} 44 | \item \code{"teal"} 45 | \item \code{"cyan"} 46 | \item \code{"gray"} 47 | }} 48 | 49 | \item{alpha}{Transparency level, a real number in (0, 1]. 50 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 51 | 52 | \item{reverse}{Logical. Should the order of the colors be reversed?} 53 | 54 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 55 | } 56 | \description{ 57 | See \code{\link[=pal_bs5]{pal_bs5()}} for details. 58 | } 59 | \examples{ 60 | library("ggplot2") 61 | 62 | data("mtcars") 63 | cor <- abs(cor(mtcars)) 64 | cor_melt <- data.frame( 65 | Var1 = rep(seq_len(nrow(cor)), times = ncol(cor)), 66 | Var2 = rep(seq_len(ncol(cor)), each = nrow(cor)), 67 | value = as.vector(cor) 68 | ) 69 | 70 | ggplot( 71 | cor_melt, 72 | aes(x = Var1, y = Var2, fill = value) 73 | ) + 74 | geom_tile(colour = "black", size = 0.3) + 75 | theme_bw() + 76 | scale_fill_bs5("teal") 77 | } 78 | \author{ 79 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 80 | } 81 | -------------------------------------------------------------------------------- /man/scale_cosmic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-cosmic.R 3 | \name{scale_color_cosmic} 4 | \alias{scale_color_cosmic} 5 | \alias{scale_colour_cosmic} 6 | \alias{scale_fill_cosmic} 7 | \title{COSMIC color scales} 8 | \usage{ 9 | scale_color_cosmic( 10 | palette = c("hallmarks_light", "hallmarks_dark", "signature_substitutions"), 11 | alpha = 1, 12 | ... 13 | ) 14 | 15 | scale_colour_cosmic( 16 | palette = c("hallmarks_light", "hallmarks_dark", "signature_substitutions"), 17 | alpha = 1, 18 | ... 19 | ) 20 | 21 | scale_fill_cosmic( 22 | palette = c("hallmarks_light", "hallmarks_dark", "signature_substitutions"), 23 | alpha = 1, 24 | ... 25 | ) 26 | } 27 | \arguments{ 28 | \item{palette}{Palette type. Currently there are three available options: 29 | \itemize{ 30 | \item \code{"signature_substitutions"} (6-color palette). 31 | \item \code{"hallmarks_light"} (10-color palette). 32 | \item \code{"hallmarks_dark"} (10-color palette). 33 | } 34 | 35 | The \code{"hallmarks_light"} option is from 36 | \href{https://pubmed.ncbi.nlm.nih.gov/21376230/}{Hanahan and Weinberg (2011)}.} 37 | 38 | \item{alpha}{Transparency level, a real number in (0, 1]. 39 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 40 | 41 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 42 | } 43 | \description{ 44 | See \code{\link[=pal_cosmic]{pal_cosmic()}} for details. 45 | } 46 | \examples{ 47 | library("ggplot2") 48 | data("diamonds") 49 | 50 | ggplot( 51 | subset(diamonds, carat >= 2.2), 52 | aes(x = table, y = price, colour = cut) 53 | ) + 54 | geom_point(alpha = 0.7) + 55 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 56 | theme_bw() + 57 | scale_color_cosmic() 58 | 59 | ggplot( 60 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 61 | aes(x = depth, fill = cut) 62 | ) + 63 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 64 | theme_bw() + 65 | scale_fill_cosmic() 66 | } 67 | \author{ 68 | Joshua H. Cook | \email{joshuacook0023@gmail.com} | 69 | \href{https://github.com/jhrcook}{@jhrcook} 70 | } 71 | -------------------------------------------------------------------------------- /man/scale_d3.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-d3.R 3 | \name{scale_color_d3} 4 | \alias{scale_color_d3} 5 | \alias{scale_colour_d3} 6 | \alias{scale_fill_d3} 7 | \title{D3.js color scales} 8 | \usage{ 9 | scale_color_d3( 10 | palette = c("category10", "category20", "category20b", "category20c"), 11 | alpha = 1, 12 | ... 13 | ) 14 | 15 | scale_colour_d3( 16 | palette = c("category10", "category20", "category20b", "category20c"), 17 | alpha = 1, 18 | ... 19 | ) 20 | 21 | scale_fill_d3( 22 | palette = c("category10", "category20", "category20b", "category20c"), 23 | alpha = 1, 24 | ... 25 | ) 26 | } 27 | \arguments{ 28 | \item{palette}{Palette type. There are four available options: 29 | \itemize{ 30 | \item \code{"category10"} (10-color palette). 31 | \item \code{"category20"} (20-color palette). 32 | \item \code{"category20b"} (20-color palette). 33 | \item \code{"category20c"} (20-color palette). 34 | }} 35 | 36 | \item{alpha}{Transparency level, a real number in (0, 1]. 37 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 38 | 39 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 40 | } 41 | \description{ 42 | See \code{\link[=pal_d3]{pal_d3()}} for details. 43 | } 44 | \examples{ 45 | library("ggplot2") 46 | data("diamonds") 47 | 48 | p1 <- ggplot( 49 | subset(diamonds, carat >= 2.2), 50 | aes(x = table, y = price, colour = cut) 51 | ) + 52 | geom_point(alpha = 0.7) + 53 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 54 | theme_bw() 55 | 56 | p2 <- ggplot( 57 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 58 | aes(x = depth, fill = cut) 59 | ) + 60 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 61 | theme_bw() 62 | 63 | p1 + scale_color_d3() 64 | p2 + scale_fill_d3() 65 | 66 | p1 + scale_color_d3(palette = "category20") 67 | p2 + scale_fill_d3(palette = "category20") 68 | 69 | p1 + scale_color_d3(palette = "category20b") 70 | p2 + scale_fill_d3(palette = "category20b") 71 | 72 | p1 + scale_color_d3(palette = "category20c") 73 | p2 + scale_fill_d3(palette = "category20c") 74 | } 75 | \references{ 76 | \url{https://github.com/d3/d3-3.x-api-reference/blob/master/Ordinal-Scales.md} 77 | } 78 | \author{ 79 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 80 | } 81 | -------------------------------------------------------------------------------- /man/scale_flatui.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-flatui.R 3 | \name{scale_color_flatui} 4 | \alias{scale_color_flatui} 5 | \alias{scale_colour_flatui} 6 | \alias{scale_fill_flatui} 7 | \title{Flat UI color scales} 8 | \usage{ 9 | scale_color_flatui( 10 | palette = c("default", "flattastic", "aussie"), 11 | alpha = 1, 12 | ... 13 | ) 14 | 15 | scale_colour_flatui( 16 | palette = c("default", "flattastic", "aussie"), 17 | alpha = 1, 18 | ... 19 | ) 20 | 21 | scale_fill_flatui( 22 | palette = c("default", "flattastic", "aussie"), 23 | alpha = 1, 24 | ... 25 | ) 26 | } 27 | \arguments{ 28 | \item{palette}{Palette type. Currently there are three available options: 29 | \itemize{ 30 | \item \code{"default"} (10-color palette). 31 | \item \code{"flattastic"} (12-color palette). 32 | \item \code{"aussie"} (10-color palette). 33 | }} 34 | 35 | \item{alpha}{Transparency level, a real number in (0, 1]. 36 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 37 | 38 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 39 | } 40 | \description{ 41 | See \code{\link[=pal_flatui]{pal_flatui()}} for details. 42 | } 43 | \examples{ 44 | library("ggplot2") 45 | data("diamonds") 46 | 47 | p1 <- ggplot( 48 | subset(diamonds, carat >= 2.2), 49 | aes(x = table, y = price, colour = cut) 50 | ) + 51 | geom_point(alpha = 0.7) + 52 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 53 | theme_bw() 54 | 55 | p2 <- ggplot( 56 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 57 | aes(x = depth, fill = cut) 58 | ) + 59 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 60 | theme_bw() 61 | 62 | p1 + scale_color_flatui() 63 | p2 + scale_fill_flatui() 64 | 65 | p1 + scale_color_flatui(palette = "default") 66 | p2 + scale_fill_flatui(palette = "default") 67 | 68 | p1 + scale_color_flatui(palette = "flattastic") 69 | p2 + scale_fill_flatui(palette = "flattastic") 70 | 71 | p1 + scale_color_flatui(palette = "aussie") 72 | p2 + scale_fill_flatui(palette = "aussie") 73 | } 74 | \author{ 75 | Clara Jégousse | \email{cat3@hi.is} 76 | } 77 | -------------------------------------------------------------------------------- /man/scale_frontiers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-frontiers.R 3 | \name{scale_color_frontiers} 4 | \alias{scale_color_frontiers} 5 | \alias{scale_colour_frontiers} 6 | \alias{scale_fill_frontiers} 7 | \title{Frontiers journal color scales} 8 | \usage{ 9 | scale_color_frontiers(palette = c("default"), alpha = 1, ...) 10 | 11 | scale_colour_frontiers(palette = c("default"), alpha = 1, ...) 12 | 13 | scale_fill_frontiers(palette = c("default"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (10-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_frontiers]{pal_frontiers()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_dark() + 39 | theme( 40 | panel.background = element_rect(fill = "#2D2D2D"), 41 | legend.key = element_rect(fill = "#2D2D2D") 42 | ) + 43 | scale_color_frontiers() 44 | 45 | ggplot( 46 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 47 | aes(x = depth, fill = cut) 48 | ) + 49 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 50 | theme_dark() + 51 | theme( 52 | panel.background = element_rect(fill = "#2D2D2D") 53 | ) + 54 | scale_fill_frontiers() 55 | } 56 | \author{ 57 | Clara Jégousse | \email{cat3@hi.is} 58 | } 59 | -------------------------------------------------------------------------------- /man/scale_futurama.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-futurama.R 3 | \name{scale_color_futurama} 4 | \alias{scale_color_futurama} 5 | \alias{scale_colour_futurama} 6 | \alias{scale_fill_futurama} 7 | \title{Futurama color scales} 8 | \usage{ 9 | scale_color_futurama(palette = c("planetexpress"), alpha = 1, ...) 10 | 11 | scale_colour_futurama(palette = c("planetexpress"), alpha = 1, ...) 12 | 13 | scale_fill_futurama(palette = c("planetexpress"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"planetexpress"} 18 | (12-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_futurama]{pal_futurama()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_futurama() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_futurama() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_gsea.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-gsea.R 3 | \name{scale_color_gsea} 4 | \alias{scale_color_gsea} 5 | \alias{scale_colour_gsea} 6 | \alias{scale_fill_gsea} 7 | \title{The GSEA GenePattern color scales} 8 | \usage{ 9 | scale_color_gsea(palette = c("default"), alpha = 1, reverse = FALSE, ...) 10 | 11 | scale_colour_gsea(palette = c("default"), alpha = 1, reverse = FALSE, ...) 12 | 13 | scale_fill_gsea(palette = c("default"), alpha = 1, reverse = FALSE, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (continuous palette with 12 base colors).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{reverse}{Logical. Should the order of the colors be reversed?} 24 | 25 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 26 | } 27 | \description{ 28 | See \code{\link[=pal_gsea]{pal_gsea()}} for details. 29 | } 30 | \examples{ 31 | library("ggplot2") 32 | 33 | data("mtcars") 34 | cor <- cor(mtcars) 35 | cor_melt <- data.frame( 36 | Var1 = rep(seq_len(nrow(cor)), times = ncol(cor)), 37 | Var2 = rep(seq_len(ncol(cor)), each = nrow(cor)), 38 | value = as.vector(cor) 39 | ) 40 | 41 | ggplot( 42 | cor_melt, 43 | aes(x = Var1, y = Var2, fill = value) 44 | ) + 45 | geom_tile(colour = "black", size = 0.3) + 46 | theme_bw() + 47 | scale_fill_gsea() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_igv.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-igv.R 3 | \name{scale_color_igv} 4 | \alias{scale_color_igv} 5 | \alias{scale_colour_igv} 6 | \alias{scale_fill_igv} 7 | \title{Integrative Genomics Viewer (IGV) color scales} 8 | \usage{ 9 | scale_color_igv(palette = c("default", "alternating"), alpha = 1, ...) 10 | 11 | scale_colour_igv(palette = c("default", "alternating"), alpha = 1, ...) 12 | 13 | scale_fill_igv(palette = c("default", "alternating"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | There are two available options: 18 | \itemize{ 19 | \item \code{"default"} (51-color palette). 20 | \item \code{"alternating"} (2-color palette). 21 | }} 22 | 23 | \item{alpha}{Transparency level, a real number in (0, 1]. 24 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 25 | 26 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 27 | } 28 | \description{ 29 | See \code{\link[=pal_igv]{pal_igv()}} for details. 30 | } 31 | \examples{ 32 | library("ggplot2") 33 | data("diamonds") 34 | 35 | p1 <- ggplot( 36 | subset(diamonds, carat >= 2.2), 37 | aes(x = table, y = price, colour = cut) 38 | ) + 39 | geom_point(alpha = 0.7) + 40 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 41 | theme_bw() 42 | 43 | p2 <- ggplot( 44 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 45 | aes(x = depth, fill = cut) 46 | ) + 47 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 48 | theme_bw() 49 | 50 | p1 + scale_color_igv() 51 | p2 + scale_fill_igv() 52 | 53 | p1 + scale_colour_manual( 54 | values = rep(pal_igv("alternating")(2), times = 3) 55 | ) 56 | p2 + scale_fill_manual( 57 | values = rep(pal_igv("alternating")(2), times = 3) 58 | ) 59 | } 60 | \author{ 61 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 62 | } 63 | -------------------------------------------------------------------------------- /man/scale_jama.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-jama.R 3 | \name{scale_color_jama} 4 | \alias{scale_color_jama} 5 | \alias{scale_colour_jama} 6 | \alias{scale_fill_jama} 7 | \title{Journal of the American Medical Association color scales} 8 | \usage{ 9 | scale_color_jama(palette = c("default"), alpha = 1, ...) 10 | 11 | scale_colour_jama(palette = c("default"), alpha = 1, ...) 12 | 13 | scale_fill_jama(palette = c("default"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (7-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_jama]{pal_jama()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_jama() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_jama() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_jco.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-jco.R 3 | \name{scale_color_jco} 4 | \alias{scale_color_jco} 5 | \alias{scale_colour_jco} 6 | \alias{scale_fill_jco} 7 | \title{Journal of Clinical Oncology color scales} 8 | \usage{ 9 | scale_color_jco(palette = c("default"), alpha = 1, ...) 10 | 11 | scale_colour_jco(palette = c("default"), alpha = 1, ...) 12 | 13 | scale_fill_jco(palette = c("default"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (10-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_jco]{pal_jco()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_jco() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_jco() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_lancet.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-lancet.R 3 | \name{scale_color_lancet} 4 | \alias{scale_color_lancet} 5 | \alias{scale_colour_lancet} 6 | \alias{scale_fill_lancet} 7 | \title{Lancet journal color scales} 8 | \usage{ 9 | scale_color_lancet(palette = c("lanonc"), alpha = 1, ...) 10 | 11 | scale_colour_lancet(palette = c("lanonc"), alpha = 1, ...) 12 | 13 | scale_fill_lancet(palette = c("lanonc"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"lanonc"} 18 | (9-color palette inspired by \emph{Lancet Oncology}).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_lancet]{pal_lancet()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_lancet() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_lancet() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_locuszoom.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-locuszoom.R 3 | \name{scale_color_locuszoom} 4 | \alias{scale_color_locuszoom} 5 | \alias{scale_colour_locuszoom} 6 | \alias{scale_fill_locuszoom} 7 | \title{LocusZoom color scales} 8 | \usage{ 9 | scale_color_locuszoom(palette = c("default"), alpha = 1, ...) 10 | 11 | scale_colour_locuszoom(palette = c("default"), alpha = 1, ...) 12 | 13 | scale_fill_locuszoom(palette = c("default"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (7-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_locuszoom]{pal_locuszoom()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_locuszoom() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_locuszoom() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_material.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-material.R 3 | \name{scale_color_material} 4 | \alias{scale_color_material} 5 | \alias{scale_colour_material} 6 | \alias{scale_fill_material} 7 | \title{Material Design color scales} 8 | \usage{ 9 | scale_color_material( 10 | palette = c("red", "pink", "purple", "deep-purple", "indigo", "blue", "light-blue", 11 | "cyan", "teal", "green", "light-green", "lime", "yellow", "amber", "orange", 12 | "deep-orange", "brown", "grey", "blue-grey"), 13 | alpha = 1, 14 | reverse = FALSE, 15 | ... 16 | ) 17 | 18 | scale_colour_material( 19 | palette = c("red", "pink", "purple", "deep-purple", "indigo", "blue", "light-blue", 20 | "cyan", "teal", "green", "light-green", "lime", "yellow", "amber", "orange", 21 | "deep-orange", "brown", "grey", "blue-grey"), 22 | alpha = 1, 23 | reverse = FALSE, 24 | ... 25 | ) 26 | 27 | scale_fill_material( 28 | palette = c("red", "pink", "purple", "deep-purple", "indigo", "blue", "light-blue", 29 | "cyan", "teal", "green", "light-green", "lime", "yellow", "amber", "orange", 30 | "deep-orange", "brown", "grey", "blue-grey"), 31 | alpha = 1, 32 | reverse = FALSE, 33 | ... 34 | ) 35 | } 36 | \arguments{ 37 | \item{palette}{Palette type. There are 19 available options: 38 | \itemize{ 39 | \item \code{"red"} 40 | \item \code{"pink"} 41 | \item \code{"purple"} 42 | \item \code{"deep-purple"} 43 | \item \code{"indigo"} 44 | \item \code{"blue"} 45 | \item \code{"light-blue"} 46 | \item \code{"cyan"} 47 | \item \code{"teal"} 48 | \item \code{"green"} 49 | \item \code{"light-green"} 50 | \item \code{"lime"} 51 | \item \code{"yellow"} 52 | \item \code{"amber"} 53 | \item \code{"orange"} 54 | \item \code{"deep-orange"} 55 | \item \code{"brown"} 56 | \item \code{"grey"} 57 | \item \code{"blue-grey"} 58 | }} 59 | 60 | \item{alpha}{Transparency level, a real number in (0, 1]. 61 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 62 | 63 | \item{reverse}{Logical. Should the order of the colors be reversed?} 64 | 65 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 66 | } 67 | \description{ 68 | See \code{\link[=pal_material]{pal_material()}} for details. 69 | } 70 | \examples{ 71 | library("ggplot2") 72 | 73 | data("mtcars") 74 | cor <- abs(cor(mtcars)) 75 | cor_melt <- data.frame( 76 | Var1 = rep(seq_len(nrow(cor)), times = ncol(cor)), 77 | Var2 = rep(seq_len(ncol(cor)), each = nrow(cor)), 78 | value = as.vector(cor) 79 | ) 80 | 81 | ggplot( 82 | cor_melt, 83 | aes(x = Var1, y = Var2, fill = value) 84 | ) + 85 | geom_tile(colour = "black", size = 0.3) + 86 | theme_bw() + 87 | scale_fill_material("blue-grey") 88 | } 89 | \author{ 90 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 91 | } 92 | -------------------------------------------------------------------------------- /man/scale_nejm.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-nejm.R 3 | \name{scale_color_nejm} 4 | \alias{scale_color_nejm} 5 | \alias{scale_colour_nejm} 6 | \alias{scale_fill_nejm} 7 | \title{NEJM color scales} 8 | \usage{ 9 | scale_color_nejm(palette = c("default"), alpha = 1, ...) 10 | 11 | scale_colour_nejm(palette = c("default"), alpha = 1, ...) 12 | 13 | scale_fill_nejm(palette = c("default"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (8-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_nejm]{pal_nejm()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_nejm() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_nejm() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_npg.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-npg.R 3 | \name{scale_color_npg} 4 | \alias{scale_color_npg} 5 | \alias{scale_colour_npg} 6 | \alias{scale_fill_npg} 7 | \title{NPG journal color scales} 8 | \usage{ 9 | scale_color_npg(palette = c("nrc"), alpha = 1, ...) 10 | 11 | scale_colour_npg(palette = c("nrc"), alpha = 1, ...) 12 | 13 | scale_fill_npg(palette = c("nrc"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"nrc"} 18 | (10-color palette inspired by \emph{Nature Reviews Cancer}).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_npg]{pal_npg()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_npg() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_npg() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_observable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-observable.R 3 | \name{scale_color_observable} 4 | \alias{scale_color_observable} 5 | \alias{scale_colour_observable} 6 | \alias{scale_fill_observable} 7 | \title{Observable 10 color scales} 8 | \usage{ 9 | scale_color_observable(palette = c("observable10"), alpha = 1, ...) 10 | 11 | scale_colour_observable(palette = c("observable10"), alpha = 1, ...) 12 | 13 | scale_fill_observable(palette = c("observable10"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"observable10"} 18 | (10-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_observable]{pal_observable()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_observable() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_observable() 48 | } 49 | \references{ 50 | Pettiross J (2023). "Crafting data colors and staying on brand." 51 | \emph{Observable blog}. \url{https://observablehq.com/blog/crafting-data-colors} 52 | } 53 | \author{ 54 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 55 | } 56 | -------------------------------------------------------------------------------- /man/scale_rickandmorty.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-rickandmorty.R 3 | \name{scale_color_rickandmorty} 4 | \alias{scale_color_rickandmorty} 5 | \alias{scale_colour_rickandmorty} 6 | \alias{scale_fill_rickandmorty} 7 | \title{Rick and Morty color scales} 8 | \usage{ 9 | scale_color_rickandmorty(palette = c("schwifty"), alpha = 1, ...) 10 | 11 | scale_colour_rickandmorty(palette = c("schwifty"), alpha = 1, ...) 12 | 13 | scale_fill_rickandmorty(palette = c("schwifty"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"schwifty"} 18 | (12-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_rickandmorty]{pal_rickandmorty()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_rickandmorty() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_rickandmorty() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_simpsons.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-simpsons.R 3 | \name{scale_color_simpsons} 4 | \alias{scale_color_simpsons} 5 | \alias{scale_colour_simpsons} 6 | \alias{scale_fill_simpsons} 7 | \title{The Simpsons color scales} 8 | \usage{ 9 | scale_color_simpsons(palette = c("springfield"), alpha = 1, ...) 10 | 11 | scale_colour_simpsons(palette = c("springfield"), alpha = 1, ...) 12 | 13 | scale_fill_simpsons(palette = c("springfield"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"springfield"} 18 | (16-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_simpsons]{pal_simpsons()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_simpsons() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_simpsons() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_startrek.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-startrek.R 3 | \name{scale_color_startrek} 4 | \alias{scale_color_startrek} 5 | \alias{scale_colour_startrek} 6 | \alias{scale_fill_startrek} 7 | \title{Star Trek color scales} 8 | \usage{ 9 | scale_color_startrek(palette = c("uniform"), alpha = 1, ...) 10 | 11 | scale_colour_startrek(palette = c("uniform"), alpha = 1, ...) 12 | 13 | scale_fill_startrek(palette = c("uniform"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"uniform"} 18 | (7-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_startrek]{pal_startrek()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_startrek() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_startrek() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /man/scale_tron.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-tron.R 3 | \name{scale_color_tron} 4 | \alias{scale_color_tron} 5 | \alias{scale_colour_tron} 6 | \alias{scale_fill_tron} 7 | \title{Tron Legacy color scales} 8 | \usage{ 9 | scale_color_tron(palette = c("legacy"), alpha = 1, ...) 10 | 11 | scale_colour_tron(palette = c("legacy"), alpha = 1, ...) 12 | 13 | scale_fill_tron(palette = c("legacy"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"legacy"} 18 | (7-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_tron]{pal_tron()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_dark() + 39 | theme( 40 | panel.background = element_rect(fill = "#2D2D2D"), 41 | legend.key = element_rect(fill = "#2D2D2D") 42 | ) + 43 | scale_color_tron() 44 | 45 | ggplot( 46 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 47 | aes(x = depth, fill = cut) 48 | ) + 49 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 50 | theme_dark() + 51 | theme( 52 | panel.background = element_rect(fill = "#2D2D2D") 53 | ) + 54 | scale_fill_tron() 55 | } 56 | \author{ 57 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 58 | } 59 | -------------------------------------------------------------------------------- /man/scale_tw3.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/continuous-tw3.R 3 | \name{scale_color_tw3} 4 | \alias{scale_color_tw3} 5 | \alias{scale_colour_tw3} 6 | \alias{scale_fill_tw3} 7 | \title{Tailwind CSS color scales} 8 | \usage{ 9 | scale_color_tw3( 10 | palette = c("slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 11 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", 12 | "violet", "purple", "fuchsia", "pink", "rose"), 13 | alpha = 1, 14 | reverse = FALSE, 15 | ... 16 | ) 17 | 18 | scale_colour_tw3( 19 | palette = c("slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 20 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", 21 | "violet", "purple", "fuchsia", "pink", "rose"), 22 | alpha = 1, 23 | reverse = FALSE, 24 | ... 25 | ) 26 | 27 | scale_fill_tw3( 28 | palette = c("slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", 29 | "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", 30 | "violet", "purple", "fuchsia", "pink", "rose"), 31 | alpha = 1, 32 | reverse = FALSE, 33 | ... 34 | ) 35 | } 36 | \arguments{ 37 | \item{palette}{Palette type. There are 22 available options: 38 | \itemize{ 39 | \item \code{"slate"} 40 | \item \code{"gray"} 41 | \item \code{"zinc"} 42 | \item \code{"neutral"} 43 | \item \code{"stone"} 44 | \item \code{"red"} 45 | \item \code{"orange"} 46 | \item \code{"amber"} 47 | \item \code{"yellow"} 48 | \item \code{"lime"} 49 | \item \code{"green"} 50 | \item \code{"emerald"} 51 | \item \code{"teal"} 52 | \item \code{"cyan"} 53 | \item \code{"sky"} 54 | \item \code{"blue"} 55 | \item \code{"indigo"} 56 | \item \code{"violet"} 57 | \item \code{"purple"} 58 | \item \code{"fuchsia"} 59 | \item \code{"pink"} 60 | \item \code{"rose"} 61 | }} 62 | 63 | \item{alpha}{Transparency level, a real number in (0, 1]. 64 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 65 | 66 | \item{reverse}{Logical. Should the order of the colors be reversed?} 67 | 68 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 69 | } 70 | \description{ 71 | See \code{\link[=pal_tw3]{pal_tw3()}} for details. 72 | } 73 | \examples{ 74 | library("ggplot2") 75 | 76 | data("mtcars") 77 | cor <- abs(cor(mtcars)) 78 | cor_melt <- data.frame( 79 | Var1 = rep(seq_len(nrow(cor)), times = ncol(cor)), 80 | Var2 = rep(seq_len(ncol(cor)), each = nrow(cor)), 81 | value = as.vector(cor) 82 | ) 83 | 84 | ggplot( 85 | cor_melt, 86 | aes(x = Var1, y = Var2, fill = value) 87 | ) + 88 | geom_tile(colour = "black", size = 0.3) + 89 | theme_bw() + 90 | scale_fill_tw3("slate") 91 | } 92 | \author{ 93 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 94 | } 95 | -------------------------------------------------------------------------------- /man/scale_uchicago.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-uchicago.R 3 | \name{scale_color_uchicago} 4 | \alias{scale_color_uchicago} 5 | \alias{scale_colour_uchicago} 6 | \alias{scale_fill_uchicago} 7 | \title{The University of Chicago color scales} 8 | \usage{ 9 | scale_color_uchicago(palette = c("default", "light", "dark"), alpha = 1, ...) 10 | 11 | scale_colour_uchicago(palette = c("default", "light", "dark"), alpha = 1, ...) 12 | 13 | scale_fill_uchicago(palette = c("default", "light", "dark"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | There are three available options: 18 | \itemize{ 19 | \item \code{"default"} (9-color palette); 20 | \item \code{"light"} (9-color light palette); 21 | \item \code{"dark"} (9-color dark palette). 22 | }} 23 | 24 | \item{alpha}{Transparency level, a real number in (0, 1]. 25 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 26 | 27 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 28 | } 29 | \description{ 30 | See \code{\link[=pal_uchicago]{pal_uchicago()}} for details. 31 | } 32 | \examples{ 33 | library("ggplot2") 34 | data("diamonds") 35 | 36 | p1 <- ggplot( 37 | subset(diamonds, carat >= 2.2), 38 | aes(x = table, y = price, colour = cut) 39 | ) + 40 | geom_point(alpha = 0.7) + 41 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 42 | theme_bw() 43 | 44 | p2 <- ggplot( 45 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 46 | aes(x = depth, fill = cut) 47 | ) + 48 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 49 | theme_bw() 50 | 51 | p1 + scale_color_uchicago() 52 | p2 + scale_fill_uchicago() 53 | 54 | p1 + scale_color_uchicago(palette = "light") 55 | p2 + scale_fill_uchicago(palette = "light") 56 | 57 | p1 + scale_color_uchicago(palette = "dark") 58 | p2 + scale_fill_uchicago(palette = "dark") 59 | } 60 | \references{ 61 | \url{https://news.uchicago.edu/sites/default/files/attachments/_uchicago.identity.guidelines.pdf} 62 | } 63 | \author{ 64 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 65 | } 66 | -------------------------------------------------------------------------------- /man/scale_ucscgb.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discrete-ucscgb.R 3 | \name{scale_color_ucscgb} 4 | \alias{scale_color_ucscgb} 5 | \alias{scale_colour_ucscgb} 6 | \alias{scale_fill_ucscgb} 7 | \title{UCSC Genome Browser color scales} 8 | \usage{ 9 | scale_color_ucscgb(palette = c("default"), alpha = 1, ...) 10 | 11 | scale_colour_ucscgb(palette = c("default"), alpha = 1, ...) 12 | 13 | scale_fill_ucscgb(palette = c("default"), alpha = 1, ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette type. 17 | Currently there is one available option: \code{"default"} 18 | (26-color palette).} 19 | 20 | \item{alpha}{Transparency level, a real number in (0, 1]. 21 | See \code{alpha} in \code{\link[grDevices:rgb]{grDevices::rgb()}} for details.} 22 | 23 | \item{...}{Additional parameters for \code{\link[ggplot2:discrete_scale]{ggplot2::discrete_scale()}}.} 24 | } 25 | \description{ 26 | See \code{\link[=pal_ucscgb]{pal_ucscgb()}} for details. 27 | } 28 | \examples{ 29 | library("ggplot2") 30 | data("diamonds") 31 | 32 | ggplot( 33 | subset(diamonds, carat >= 2.2), 34 | aes(x = table, y = price, colour = cut) 35 | ) + 36 | geom_point(alpha = 0.7) + 37 | geom_smooth(method = "loess", alpha = 0.1, size = 1, span = 1) + 38 | theme_bw() + 39 | scale_color_ucscgb() 40 | 41 | ggplot( 42 | subset(diamonds, carat > 2.2 & depth > 55 & depth < 70), 43 | aes(x = depth, fill = cut) 44 | ) + 45 | geom_histogram(colour = "black", binwidth = 1, position = "dodge") + 46 | theme_bw() + 47 | scale_fill_ucscgb() 48 | } 49 | \author{ 50 | Nan Xiao | \email{me@nanx.me} | \url{https://nanx.me} 51 | } 52 | -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nanxstats/ggsci/b5bf1fddc7a74aac06643998b0e28638df070db3/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /vignettes/custom.css: -------------------------------------------------------------------------------- 1 | /* custom css style for Nan Xiao's R package vignettes */ 2 | 3 | body { 4 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; 5 | font-size: 16px; 6 | line-height: 1.5; 7 | color: #212529; 8 | padding-top: 25px; 9 | padding-bottom: 25px; 10 | } 11 | 12 | h1.title { 13 | padding-bottom: 10px; 14 | } 15 | 16 | h1, h2, h3, h4, h5, h6 { 17 | color: #212529; 18 | font-weight: 700; 19 | } 20 | 21 | h1, h1.title { 22 | font-size: 30px; 23 | } 24 | 25 | h2 { 26 | font-size: 24px; 27 | } 28 | 29 | h3 { 30 | font-size: 20px; 31 | } 32 | 33 | h4 { 34 | font-size: 16px; 35 | } 36 | 37 | h5 { 38 | font-size: 16px; 39 | } 40 | 41 | h6 { 42 | font-size: 16px; 43 | } 44 | 45 | h4.author { 46 | padding-bottom: 10px; 47 | } 48 | 49 | h4.author>em { 50 | font-size: 14px; 51 | font-style: normal; 52 | font-weight: 300; 53 | } 54 | 55 | h4.date { 56 | padding-bottom: 10px; 57 | } 58 | 59 | h4.date>em { 60 | font-size: 14px; 61 | font-style: normal; 62 | font-weight: 300; 63 | } 64 | 65 | a { 66 | color: #4582EC; 67 | } 68 | 69 | a:hover, a:focus, a:active { 70 | color: #1559CF; 71 | } 72 | 73 | a:focus { 74 | outline: thin dotted; 75 | } 76 | 77 | a:hover, a:active { 78 | outline: 0; 79 | } 80 | 81 | pre, code { 82 | font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; 83 | background-color: #f8f9fa; 84 | border: none; 85 | } 86 | 87 | /* float toc */ 88 | 89 | .list-group-item.active, .list-group-item.active:focus, .list-group-item.active:hover { 90 | background-color: #4582EC; 91 | border-color: #4582EC; 92 | } 93 | 94 | /* figure */ 95 | 96 | div.figure { 97 | text-align: center; 98 | } 99 | 100 | p.caption { 101 | text-align: center; 102 | } 103 | 104 | .footnote { 105 | position: absolute; 106 | bottom: 3em; 107 | padding-right: 4em; 108 | color: #4287c7; 109 | } 110 | 111 | .remark-code, .remark-inline-code { 112 | font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; 113 | background-color: #c8c8c8; 114 | } 115 | 116 | .remark-code-line-highlighted { 117 | background-color: #fff; 118 | } 119 | 120 | .remark-slide .title-slide { 121 | padding-left: 340px; 122 | padding-top: 110px; 123 | } 124 | 125 | .title-slide h1, .title-slide h2, .title-slide h3 { 126 | color: #585858; 127 | } 128 | 129 | .title-slide h1, .title-slide h2 { 130 | font-weight: 700; 131 | margin-top: 20px; 132 | margin-bottom: 80px; 133 | } 134 | 135 | .title-slide h3 { 136 | font-weight: 300; 137 | font-weight: normal; 138 | margin: 0; 139 | } 140 | 141 | .dark-green { 142 | background-color: #789d57; 143 | } 144 | 145 | .dark-green h2, .dark-green h1 { 146 | color: #fff; 147 | } 148 | 149 | .dark-gray { 150 | background-color: #585858; 151 | } 152 | 153 | .dark-gray h2, .dark-gray h1 { 154 | color: #fff; 155 | } 156 | 157 | /* Two-column layout */ 158 | 159 | .left-column { 160 | color: #777; 161 | width: 20%; 162 | height: 92%; 163 | float: left; 164 | } 165 | 166 | .left-column h2:last-of-type, .left-column h3:last-child { 167 | color: #000; 168 | } 169 | 170 | .right-column { 171 | width: 75%; 172 | float: right; 173 | padding-top: 1em; 174 | } 175 | 176 | .pull-left { 177 | float: left; 178 | width: 47%; 179 | } 180 | 181 | .pull-right { 182 | float: right; 183 | width: 47%; 184 | } 185 | 186 | .pull-right~* { 187 | clear: both; 188 | } 189 | 190 | img, video, iframe { 191 | max-width: 100%; 192 | } 193 | 194 | blockquote { 195 | border-left: solid 5px lightgray; 196 | padding-left: 1em; 197 | } 198 | 199 | table { 200 | margin: auto; 201 | border-bottom: 1px solid #666; 202 | } 203 | 204 | table thead th { 205 | border-bottom: 1px solid #ddd; 206 | } 207 | 208 | th, td { 209 | padding: 5px; 210 | } 211 | 212 | thead, tfoot, tr:nth-child(even) { 213 | background: #eee 214 | } 215 | -------------------------------------------------------------------------------- /vignettes/ggsci-faq.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Frequently Asked Questions about ggsci" 3 | output: 4 | rmarkdown::html_document: 5 | toc: true 6 | toc_float: false 7 | toc_depth: 2 8 | number_sections: false 9 | highlight: "textmate" 10 | css: custom.css 11 | vignette: > 12 | %\VignetteEngine{knitr::rmarkdown} 13 | %\VignetteIndexEntry{Frequently Asked Questions about ggsci} 14 | --- 15 | 16 | ```{r, include=FALSE} 17 | knitr::knit_hooks$set(pngquant = knitr::hook_pngquant) 18 | 19 | knitr::opts_chunk$set( 20 | message = FALSE, 21 | collapse = TRUE, 22 | comment = "#>", 23 | dev = "ragg_png", 24 | dpi = 72, 25 | fig.retina = 2, 26 | fig.width = 3.3334 / 0.618, 27 | fig.height = 3.3334, 28 | fig.align = "center", 29 | out.width = "65%", 30 | pngquant = "--speed=1 --quality=50" 31 | ) 32 | ``` 33 | 34 | ## What if my data has more categories than the number of colors offered? 35 | 36 | Although it is recommended that we do not encode too many categories 37 | in different colors, in practice, one can still create an "adaptive" 38 | color palette based on the existing discrete color palettes in ggsci. 39 | 40 | See this blog post for a detailed guide on creating 41 | [adaptive ggplot2 color scales with color interpolation](https://nanx.me/blog/post/ggplot2-color-interpolation/). 42 | 43 | ## Use a color scale consistently for multiple plots in a document 44 | 45 | To apply a color scale for all plots in a document and avoid repetition, 46 | a simple solution is setting the two global options 47 | `ggplot2.discrete.colour` and `ggplot2.discrete.fill`. For example: 48 | 49 | ```r 50 | library("ggplot2") 51 | 52 | p <- ggplot(mpg, aes(displ, hwy, colour = factor(cyl), fill = factor(cyl))) + 53 | geom_point() + 54 | geom_smooth(method = "lm") + 55 | theme_bw() 56 | 57 | p 58 | 59 | # Set global options 60 | options( 61 | ggplot2.discrete.colour = ggsci::scale_colour_d3, 62 | ggplot2.discrete.fill = ggsci::scale_fill_d3 63 | ) 64 | 65 | p 66 | 67 | # Restore original options after use 68 | options( 69 | ggplot2.discrete.colour = NULL, 70 | ggplot2.discrete.fill = NULL 71 | ) 72 | 73 | p 74 | ``` 75 | 76 | ## Customize color ordering in a palette 77 | 78 | You can customize the color selection and ordering of any discrete 79 | color palette in ggsci by using the following function that returns 80 | a custom color scale function. This method is flexible and encourages 81 | code reuse. 82 | 83 | ```{r} 84 | #' Define a custom color scale 85 | #' 86 | #' @param pal Name of the color palette, as part of the 87 | #' original palette function name. 88 | #' @param palette Palette type, as defined in the 89 | #' original palette function (optional). 90 | #' @param n Number of (first) colors to fetch from the original palette. 91 | #' @param order A vector of color index (optional). 92 | #' @param alpha Transparency level. 93 | #' 94 | #' @return A custom color scale function. 95 | scale_color_custom <- function(pal, palette, n, order, alpha = 1) { 96 | pal <- getFromNamespace(paste0("pal_", pal), "ggsci") 97 | 98 | colors <- if (missing(palette)) { 99 | pal(alpha = alpha)(n) 100 | } else { 101 | pal(palette = palette, alpha = alpha)(n) 102 | } 103 | 104 | if (length(order) > length(colors)) { 105 | stop("The length of order exceeds the number of colors.", call. = FALSE) 106 | } 107 | colors <- if (!missing(order)) colors[order] 108 | 109 | ggplot2::scale_color_manual(values = colors) 110 | } 111 | ``` 112 | 113 | Use `scale_color_custom()` in an example: 114 | 115 | ```{r} 116 | library(ggplot2) 117 | library(ggsci) 118 | 119 | set.seed(42) 120 | df <- data.frame( 121 | x = rnorm(100), 122 | y = rnorm(100), 123 | group = factor(sample(1:5, 100, replace = TRUE)) 124 | ) 125 | 126 | p <- ggplot(df, aes(x = x, y = y, color = group)) + 127 | geom_point(size = 3) + 128 | theme_minimal() 129 | 130 | p + scale_color_custom("d3", palette = "category20", n = 20, order = c(14, 11, 13, 12, 15)) 131 | ``` 132 | --------------------------------------------------------------------------------