├── .github ├── .gitignore └── workflows │ └── R-CMD-check.yaml ├── images ├── crait.png ├── gley.png ├── 0-logo.png ├── podzol.png ├── redox2.png ├── eutrostox.png ├── alaquod-palette.png ├── bangor-palette.png ├── pywell-palette.png ├── redox-palette.png ├── rendoll-palette.png ├── durorthod-palette.png ├── natrudoll-palette.png ├── paleustalf-palette.png └── vitrixerand-palette.png ├── .gitignore ├── tests ├── testthat.R └── testthat │ └── test-soilpalettes.R ├── readme_files └── figure-gfm │ ├── misc-1.png │ ├── misc-2.png │ ├── misc-3.png │ ├── misc-4.png │ ├── orders-1.png │ ├── orders-2.png │ ├── orders-3.png │ ├── orders-4.png │ ├── orders-5.png │ ├── orders-6.png │ ├── orders-7.png │ ├── orders-8.png │ ├── series-1.png │ ├── series-2.png │ ├── usage1-1.png │ ├── usage2-1.png │ ├── usage3-1.png │ ├── usage4-1.png │ └── usage5-1.png ├── .Rbuildignore ├── NAMESPACE ├── man ├── print.palette.Rd ├── soil_palettes.Rd └── soil_palette.Rd ├── DESCRIPTION ├── soilpalettes.Rproj ├── R ├── test.R └── soilpalettes.R ├── LICENSE ├── images.md ├── images.Rmd ├── README.md └── readme.Rmd /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /images/crait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/crait.png -------------------------------------------------------------------------------- /images/gley.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/gley.png -------------------------------------------------------------------------------- /images/0-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/0-logo.png -------------------------------------------------------------------------------- /images/podzol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/podzol.png -------------------------------------------------------------------------------- /images/redox2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/redox2.png -------------------------------------------------------------------------------- /images/eutrostox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/eutrostox.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | 6 | # OS files 7 | .DS_Store 8 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(soilpalettes) 3 | 4 | test_check("soilpalettes") 5 | -------------------------------------------------------------------------------- /images/alaquod-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/alaquod-palette.png -------------------------------------------------------------------------------- /images/bangor-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/bangor-palette.png -------------------------------------------------------------------------------- /images/pywell-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/pywell-palette.png -------------------------------------------------------------------------------- /images/redox-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/redox-palette.png -------------------------------------------------------------------------------- /images/rendoll-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/rendoll-palette.png -------------------------------------------------------------------------------- /images/durorthod-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/durorthod-palette.png -------------------------------------------------------------------------------- /images/natrudoll-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/natrudoll-palette.png -------------------------------------------------------------------------------- /images/paleustalf-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/paleustalf-palette.png -------------------------------------------------------------------------------- /images/vitrixerand-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/images/vitrixerand-palette.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/misc-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/misc-1.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/misc-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/misc-2.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/misc-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/misc-3.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/misc-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/misc-4.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/orders-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/orders-1.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/orders-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/orders-2.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/orders-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/orders-3.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/orders-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/orders-4.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/orders-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/orders-5.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/orders-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/orders-6.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/orders-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/orders-7.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/orders-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/orders-8.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/series-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/series-1.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/series-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/series-2.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/usage1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/usage1-1.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/usage2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/usage2-1.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/usage3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/usage3-1.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/usage4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/usage4-1.png -------------------------------------------------------------------------------- /readme_files/figure-gfm/usage5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaizadp/soilpalettes/HEAD/readme_files/figure-gfm/usage5-1.png -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | 4 | images/ 5 | readme_files/ 6 | 7 | .Rmd 8 | .md 9 | 10 | ^\.github$ 11 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(print,palette) 4 | export(soil_palette) 5 | export(soil_palettes) 6 | importFrom(grDevices,rgb) 7 | importFrom(graphics,image) 8 | importFrom(graphics,par) 9 | importFrom(graphics,rect) 10 | importFrom(graphics,text) 11 | importFrom(stats,median) 12 | -------------------------------------------------------------------------------- /man/print.palette.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/soilpalettes.R 3 | \name{print.palette} 4 | \alias{print.palette} 5 | \title{Palette Print Function} 6 | \usage{ 7 | \method{print}{palette}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{TODO} 11 | 12 | \item{...}{TODO} 13 | } 14 | \value{ 15 | TODO 16 | } 17 | \description{ 18 | Palette Print Function 19 | } 20 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: soilpalettes 2 | Type: Package 3 | Title: A Soil Color Palette Package 4 | Version: 0.1.0 5 | Author: Kaizad F. Patel & Ben Bond-Lamberty 6 | Maintainer: Kaizad F. Patel 7 | Description: Colorblind-friendly color palettes for R inspired by soil profiles. 8 | License: MIT + file LICENSE 9 | Encoding: UTF-8 10 | LazyData: true 11 | RoxygenNote: 7.0.2 12 | Suggests: 13 | testthat 14 | -------------------------------------------------------------------------------- /soilpalettes.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 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace 19 | -------------------------------------------------------------------------------- /man/soil_palettes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/soilpalettes.R 3 | \docType{data} 4 | \name{soil_palettes} 5 | \alias{soil_palettes} 6 | \title{Complete list of palettes} 7 | \format{An object of class \code{list} of length 13.} 8 | \usage{ 9 | soil_palettes 10 | } 11 | \description{ 12 | Use \code{names(soil_palettes)} to view list of palette names. 13 | Currently: "durorthod" "rendoll" "paleustalf" "natrudoll" "alaquod2" "alaquod" 14 | } 15 | \keyword{datasets} 16 | -------------------------------------------------------------------------------- /R/test.R: -------------------------------------------------------------------------------- 1 | # source("soilpalettes.R") 2 | # library(ggplot2) 3 | # 4 | # pal=soil_palette("alaquod2", 5,type = "discrete") 5 | # ggplot(diamonds, aes(carat, fill = cut)) + 6 | # geom_density(position = "stack") + 7 | # scale_fill_manual(values=pal) + 8 | # theme_classic() 9 | # 10 | # ggplot(diamonds, aes(x = x, y = y, color = carat)) + 11 | # #geom_density(position = "stack") + 12 | # geom_point()+ 13 | # scale_color_gradientn(colors=pal) + 14 | # theme_classic() 15 | # 16 | # soil_palette(name="durorthod",n=5,type = "discrete") 17 | # soil_palette(name="rendoll",n=5,type = "discrete") 18 | # soil_palette(name="paleustalf",n=7,type = "discrete") 19 | # soil_palette(name="natrudoll",n=7,type = "discrete") 20 | # soil_palette(name="alaquod2",n=7,type = "continuous") 21 | # 22 | -------------------------------------------------------------------------------- /tests/testthat/test-soilpalettes.R: -------------------------------------------------------------------------------- 1 | test_that("soil_palette works", { 2 | # Error on bad input 3 | expect_error(soil_palette(1, n = 100, type = "continuous", direction = 1)) 4 | expect_error(soil_palette("durorthod", n = "100", type = "continuous", direction = 1)) 5 | expect_error(soil_palette("durorthod", n = 100, type = 1, direction = 1)) 6 | expect_error(soil_palette("durorthod", n = 100, type = "continuous", direction = "1")) 7 | expect_error(soil_palette("durorthod", n = 100, type = "continuous", direction = 2), 8 | regexp = "direction must be 1 or -1") 9 | 10 | x <- soil_palette("durorthod", n = 100, type = "continuous", direction = 1) 11 | expect_s3_class(x, "palette") 12 | }) 13 | 14 | test_that("print.palette works", { 15 | # Error on bad input 16 | expect_error(print.palette(1)) 17 | 18 | x <- soil_palette("durorthod", n = 100, type = "continuous", direction = 1) 19 | expect_null(print.palette(x)) 20 | }) 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Kaizad F. Patel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /man/soil_palette.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/soilpalettes.R 3 | \name{soil_palette} 4 | \alias{soil_palette} 5 | \title{Soil Palette Generator.} 6 | \usage{ 7 | soil_palette(name, n, type = c("discrete", "continuous"), direction = 1) 8 | } 9 | \arguments{ 10 | \item{name}{Name of the color palette. Options are \code{durorthod}, \code{rendoll}, \code{paleustalf}, 11 | \code{natrudoll}, \code{alaquod2}, \code{alaquod}} 12 | 13 | \item{n}{Number of colors in the palette. Palletes include 5 colors, which can be used discretely, 14 | or if more are desired, used as a gradient. If omitted, n = length of palette.} 15 | 16 | \item{type}{Usage of palette as "continuous" or "discrete". Continuous usage interpolates between colors to create 17 | a scale of values. If omitted, function assumes continuous if n > length of palette, and discrete if n < length of palette.} 18 | 19 | \item{direction}{(TODO)} 20 | } 21 | \value{ 22 | TODO 23 | } 24 | \description{ 25 | This function builds palettes based on soil profiles. 26 | View photos for each palette \href{https://github.com/kaizadp/soilpalettes}{On Github}. 27 | } 28 | \examples{ 29 | soil_palette("durorthod",n=100,type="continuous") 30 | soil_palette("durorthod",3) 31 | soil_palette("durorthod", 50) 32 | } 33 | -------------------------------------------------------------------------------- /images.md: -------------------------------------------------------------------------------- 1 | soilpalettes 2 | ================ 3 | 4 | These are the soil profiles that inspired the color palettes. Color 5 | palettes were created using [Chroma.js](https://gka.github.io/palettes/) 6 | and [Coolors](https://coolors.co). 7 | 8 | ----- 9 | 10 | **alaquod** Aeric Alaquod, NC. 11 | *source [University of Idaho - 12 | CALS](https://www.uidaho.edu/cals/soil-orders)* 13 | ![alaquod](images/alaquod-palette.png) 14 | 15 | **durorthod** Typic Durorthod 16 | *source [University of Idaho - 17 | CALS](https://www.uidaho.edu/cals/soil-orders)* 18 | ![durorthod](images/durorthod-palette.png) 19 | 20 | **natrudoll** 21 | *source [University of Idaho - 22 | CALS](https://www.uidaho.edu/cals/soil-orders)* 23 | ![natrudoll](images/natrudoll-palette.png) 24 | 25 | **paleustalf** Udic Paleustalf 26 | *source [University of Idaho - 27 | CALS](https://www.uidaho.edu/cals/soil-orders)* 28 | ![paleustalf](images/paleustalf-palette.png) 29 | 30 | **rendoll** 31 | *source [University of Idaho - 32 | CALS](https://www.uidaho.edu/cals/soil-orders)* 33 | ![rendoll](images/rendoll-palette.png) 34 | 35 | **vitrixerand** 36 | *source [University of Idaho - 37 | CALS](https://www.uidaho.edu/cals/soil-orders)* 38 | ![vitrixerand](images/vitrixerand-palette.png) 39 | 40 | **bangor** Bangor series (Typic Haplorthods, Maine USA) 41 | ![bangor](images/bangor-palette.png) 42 | 43 | **pywell** Pywell series (Typic Haplosaprist, Idaho USA) 44 | *source [University of Idaho - 45 | CALS](https://www.uidaho.edu/cals/soil-orders)* 46 | ![pywell](images/pywell-palette.png) 47 | -------------------------------------------------------------------------------- /images.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "soilpalettes" 3 | output: github_document 4 | --- 5 | 6 | These are the soil profiles that inspired the color palettes. 7 | Color palettes were created using [Chroma.js](https://gka.github.io/palettes/) and [Coolors](https://coolors.co). 8 | 9 | 10 | ---- 11 | 12 | **alaquod** Aeric Alaquod, NC. 13 | *source [University of Idaho - CALS](https://www.uidaho.edu/cals/soil-orders)* 14 | ![alaquod](images/alaquod-palette.png) 15 | 16 | **durorthod** Typic Durorthod 17 | *source [University of Idaho - CALS](https://www.uidaho.edu/cals/soil-orders)* 18 | ![durorthod](images/durorthod-palette.png) 19 | 20 | **natrudoll** 21 | *source [University of Idaho - CALS](https://www.uidaho.edu/cals/soil-orders)* 22 | ![natrudoll](images/natrudoll-palette.png) 23 | 24 | 25 | **paleustalf** Udic Paleustalf 26 | *source [University of Idaho - CALS](https://www.uidaho.edu/cals/soil-orders)* 27 | ![paleustalf](images/paleustalf-palette.png) 28 | 29 | **rendoll** 30 | *source [University of Idaho - CALS](https://www.uidaho.edu/cals/soil-orders)* 31 | ![rendoll](images/rendoll-palette.png) 32 | 33 | **vitrixerand** 34 | *source [University of Idaho - CALS](https://www.uidaho.edu/cals/soil-orders)* 35 | ![vitrixerand](images/vitrixerand-palette.png) 36 | 37 | 38 | **bangor** Bangor series (Typic Haplorthods, Maine USA) 39 | ![bangor](images/bangor-palette.png) 40 | 41 | 42 | **pywell** Pywell series (Typic Haplosaprist, Idaho USA) 43 | *source [University of Idaho - CALS](https://www.uidaho.edu/cals/soil-orders)* 44 | ![pywell](images/pywell-palette.png) 45 | 46 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | pull_request: 6 | branches: 7 | - master 8 | 9 | name: R-CMD-check 10 | 11 | jobs: 12 | R-CMD-check: 13 | runs-on: ${{ matrix.config.os }} 14 | 15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | config: 21 | - {os: macOS-latest, r: 'devel'} 22 | - {os: macOS-latest, r: 'release'} 23 | - {os: windows-latest, r: 'release'} 24 | - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 25 | - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 26 | - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 27 | - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 28 | - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 29 | 30 | env: 31 | R_REMOTES_NO_ERRORS_FROM_WARNINGS: true 32 | RSPM: ${{ matrix.config.rspm }} 33 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 34 | 35 | steps: 36 | - uses: actions/checkout@v2 37 | 38 | - uses: r-lib/actions/setup-r@master 39 | with: 40 | r-version: ${{ matrix.config.r }} 41 | 42 | - uses: r-lib/actions/setup-pandoc@master 43 | 44 | - name: Query dependencies 45 | run: | 46 | install.packages('remotes') 47 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) 48 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") 49 | shell: Rscript {0} 50 | 51 | - name: Cache R packages 52 | if: runner.os != 'Windows' 53 | uses: actions/cache@v1 54 | with: 55 | path: ${{ env.R_LIBS_USER }} 56 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} 57 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- 58 | 59 | - name: Install system dependencies 60 | if: runner.os == 'Linux' 61 | env: 62 | RHUB_PLATFORM: linux-x86_64-ubuntu-gcc 63 | run: | 64 | Rscript -e "remotes::install_github('r-hub/sysreqs')" 65 | sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") 66 | sudo -s eval "$sysreqs" 67 | 68 | - name: Install dependencies 69 | run: | 70 | remotes::install_deps(dependencies = TRUE) 71 | remotes::install_cran("rcmdcheck") 72 | shell: Rscript {0} 73 | 74 | - name: Session info 75 | run: | 76 | options(width = 100) 77 | pkgs <- installed.packages()[, "Package"] 78 | sessioninfo::session_info(pkgs, include_base = TRUE) 79 | shell: Rscript {0} 80 | 81 | - name: Check 82 | env: 83 | _R_CHECK_CRAN_INCOMING_: false 84 | run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") 85 | shell: Rscript {0} 86 | 87 | - name: Show testthat output 88 | if: always() 89 | run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true 90 | shell: bash 91 | 92 | - name: Upload check results 93 | if: failure() 94 | uses: actions/upload-artifact@master 95 | with: 96 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results 97 | path: check 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # soilpalettes 5 | 6 | 7 | 8 | [![DOI](https://zenodo.org/badge/257353182.svg)](https://zenodo.org/badge/latestdoi/257353182) 9 | [![R build 10 | status](https://github.com/kaizadp/soilpalettes/workflows/R-CMD-check/badge.svg)](https://github.com/kaizadp/soilpalettes/actions) 11 | 12 | 13 | This package contains color palettes for RStudio, inspired by soil 14 | profiles. Palettes are colorblind-friendly and were created using 15 | [Chroma.js](https://gka.github.io/palettes/) and 16 | [Coolors](https://coolors.co). 17 | 18 | Source images and color hex values can be found in the 19 | [`images.md`](https://github.com/kaizadp/soilpalettes/blob/master/images.md) 20 | file in the root directory. 21 | 22 | ----- 23 | 24 | ### install package 25 | 26 | ``` r 27 | # install.packages("devtools") 28 | devtools::install_github("kaizadp/soilpalettes") 29 | ``` 30 | 31 | ----- 32 | 33 |
34 | 35 | Palettes 36 | 37 | #### soil orders, suborders, and great groups 38 | 39 | ![](readme_files/figure-gfm/orders-1.png)![](readme_files/figure-gfm/orders-2.png)![](readme_files/figure-gfm/orders-3.png)![](readme_files/figure-gfm/orders-4.png)![](readme_files/figure-gfm/orders-5.png)![](readme_files/figure-gfm/orders-6.png)![](readme_files/figure-gfm/orders-7.png)![](readme_files/figure-gfm/orders-8.png) 40 | 41 | #### soil series 42 | 43 | ![](readme_files/figure-gfm/series-1.png)![](readme_files/figure-gfm/series-2.png) 44 | 45 | #### others 46 | 47 | ![](readme_files/figure-gfm/misc-1.png)![](readme_files/figure-gfm/misc-2.png)![](readme_files/figure-gfm/misc-3.png)![](readme_files/figure-gfm/misc-4.png) 48 | 49 | ----- 50 | 51 |
52 | 53 |
54 | 55 | Examples 56 | 57 | ``` r 58 | library(ggplot2) 59 | 60 | ggplot(data=iris, aes(x=Sepal.Width, fill = Species))+ 61 | geom_histogram(binwidth=0.2, color="black") + 62 | xlab("Sepal Width") + ylab("Frequency") + 63 | ggtitle("Histogram of Sepal Width") + theme_bw()+ 64 | 65 | scale_fill_manual(values = soil_palette("rendoll",3)) 66 | ``` 67 | 68 | ![](readme_files/figure-gfm/usage1-1.png) 69 | 70 | ``` r 71 | ggplot(data=iris, aes(x=Sepal.Width, fill=Species)) + 72 | geom_density(stat="density", alpha=(0.6)) + 73 | xlab("Sepal Width") + ylab("Density") + 74 | ggtitle("Histogram & Density Curve of Sepal Width") + theme_bw()+ 75 | 76 | scale_fill_manual(values = soil_palette("paleustalf",3)) 77 | ``` 78 | 79 | ![](readme_files/figure-gfm/usage2-1.png) 80 | 81 | ``` r 82 | library(palmerpenguins) 83 | 84 | ggplot(penguins, aes(x = bill_length_mm, y = bill_depth_mm, color = species))+ 85 | geom_point()+ 86 | labs(x = "Bill length (mm)", y = "Bill depth (mm)", 87 | title = "Scatterplot of penguin bill dimensions", 88 | subtitle = "data = Palmer Penguins")+ 89 | theme_bw()+ 90 | 91 | scale_color_manual(values = soil_palette("paleustalf", 3)) 92 | ``` 93 | 94 | ![](readme_files/figure-gfm/usage3-1.png) 95 | 96 | ``` r 97 | ggplot(penguins, aes(y = body_mass_g, x = species, fill = species))+ 98 | geom_violin(alpha = 0.5)+ 99 | geom_dotplot(binaxis = "y", color = "black", fill="black", dotsize=0.3, stackdir = "center", binpositions="all")+ 100 | labs(y = "Body mass (g)", x = "", 101 | title = "Violin plot of penguin body mass", 102 | subtitle = "data = Palmer Penguins")+ 103 | theme_bw()+ 104 | 105 | scale_fill_manual(values = soil_palette("podzol", 3)) 106 | ``` 107 | 108 | ![](readme_files/figure-gfm/usage4-1.png) 109 | 110 | ``` r 111 | ggplot(penguins, aes(x = bill_length_mm, y = bill_depth_mm, color = bill_length_mm))+ 112 | geom_point()+ 113 | labs(x = "Bill length (mm)", y = "Bill depth (mm)", 114 | title = "Scatterplot of penguin bill dimensions", 115 | subtitle = "data = Palmer Penguins")+ 116 | theme_bw()+ 117 | 118 | scale_color_gradientn(colors = rev(soil_palette("redox2",5))) 119 | ``` 120 | 121 | ![](readme_files/figure-gfm/usage5-1.png) 122 | 123 |
124 | 125 |
126 | 127 | Acknowledgments and Contributions 128 | 129 | Code structure was modelled after the 130 | [`PNWColors`](https://github.com/jakelawlor/PNWColors) and 131 | [`wesanderson`](https://github.com/karthik/wesanderson) packages. 132 | Contribute soil palettes in the 133 | [issues](https://github.com/kaizadp/soilpalettes/issues/6). 134 | 135 | 136 | -------------------------------------------------------------------------------- /readme.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "" 3 | output: github_document 4 | --- 5 | 6 | ```{r echo=FALSE} 7 | knitr::opts_chunk$set( 8 | collapse = TRUE, 9 | echo=FALSE, 10 | message = FALSE, 11 | warning = FALSE, 12 | error = FALSE, 13 | comment = "#>", 14 | fig.height = 1 15 | ) 16 | ``` 17 | 18 | 19 | 20 | 21 | # soilpalettes 22 | 23 | 24 | [![DOI](https://zenodo.org/badge/257353182.svg)](https://zenodo.org/badge/latestdoi/257353182) 25 | [![R build status](https://github.com/kaizadp/soilpalettes/workflows/R-CMD-check/badge.svg)](https://github.com/kaizadp/soilpalettes/actions) 26 | 27 | 28 | This package contains color palettes for RStudio, inspired by soil profiles. 29 | Palettes are colorblind-friendly and were created using [Chroma.js](https://gka.github.io/palettes/) and [Coolors](https://coolors.co). 30 | 31 | 32 | Source images and color hex values can be found in the [`images.md`](https://github.com/kaizadp/soilpalettes/blob/master/images.md) file in the root directory. 33 | 34 | --- 35 | 36 | ### install package 37 | 38 | ```{r echo = TRUE, message=FALSE,warning=FALSE} 39 | # install.packages("devtools") 40 | devtools::install_github("kaizadp/soilpalettes") 41 | ``` 42 | 43 | ---- 44 | 45 |
46 | Palettes 47 | 48 | #### soil orders, suborders, and great groups 49 | ```{r orders, echo = FALSE} 50 | library(soilpalettes) 51 | 52 | soil_palette(name="alaquod",5) 53 | soil_palette(name="durorthod",5) 54 | soil_palette(name="eutrostox",5) 55 | soil_palette(name="natrudoll",5) 56 | soil_palette(name="paleustalf",5) 57 | soil_palette(name="podzol",5) 58 | soil_palette(name="rendoll",5) 59 | soil_palette(name="vitrixerand",5) 60 | 61 | 62 | ``` 63 | 64 | #### soil series 65 | ```{r series, echo = FALSE} 66 | soil_palette(name="bangor",5) 67 | soil_palette(name="pywell",5) 68 | ``` 69 | 70 | #### others 71 | 72 | ```{r misc, echo = FALSE} 73 | soil_palette(name="redox",5) 74 | soil_palette(name="redox2",5) 75 | soil_palette(name="crait",5) 76 | soil_palette(name="gley",5) 77 | 78 | ``` 79 | 80 | ---- 81 | 82 |
83 | 84 |
85 | Examples 86 | ```{r usage1, fig.height=4, fig.width=5, echo=TRUE} 87 | library(ggplot2) 88 | 89 | ggplot(data=iris, aes(x=Sepal.Width, fill = Species))+ 90 | geom_histogram(binwidth=0.2, color="black") + 91 | xlab("Sepal Width") + ylab("Frequency") + 92 | ggtitle("Histogram of Sepal Width") + theme_bw()+ 93 | 94 | scale_fill_manual(values = soil_palette("rendoll",3)) 95 | ``` 96 | 97 | ```{r usage2, fig.height=4, fig.width=5, echo=TRUE} 98 | ggplot(data=iris, aes(x=Sepal.Width, fill=Species)) + 99 | geom_density(stat="density", alpha=(0.6)) + 100 | xlab("Sepal Width") + ylab("Density") + 101 | ggtitle("Histogram & Density Curve of Sepal Width") + theme_bw()+ 102 | 103 | scale_fill_manual(values = soil_palette("paleustalf",3)) 104 | 105 | ``` 106 | 107 | ```{r usage3, fig.height=4, fig.width=5, echo=TRUE} 108 | library(palmerpenguins) 109 | 110 | ggplot(penguins, aes(x = bill_length_mm, y = bill_depth_mm, color = species))+ 111 | geom_point()+ 112 | labs(x = "Bill length (mm)", y = "Bill depth (mm)", 113 | title = "Scatterplot of penguin bill dimensions", 114 | subtitle = "data = Palmer Penguins")+ 115 | theme_bw()+ 116 | 117 | scale_color_manual(values = soil_palette("paleustalf", 3)) 118 | ``` 119 | 120 | ```{r usage4, fig.height=4, fig.width=5, echo=TRUE} 121 | ggplot(penguins, aes(y = body_mass_g, x = species, fill = species))+ 122 | geom_violin(alpha = 0.5)+ 123 | geom_dotplot(binaxis = "y", color = "black", fill="black", dotsize=0.3, stackdir = "center", binpositions="all")+ 124 | labs(y = "Body mass (g)", x = "", 125 | title = "Violin plot of penguin body mass", 126 | subtitle = "data = Palmer Penguins")+ 127 | theme_bw()+ 128 | 129 | scale_fill_manual(values = soil_palette("podzol", 3)) 130 | ``` 131 | 132 | ```{r usage5, fig.height=4, fig.width=5, echo=TRUE} 133 | ggplot(penguins, aes(x = bill_length_mm, y = bill_depth_mm, color = bill_length_mm))+ 134 | geom_point()+ 135 | labs(x = "Bill length (mm)", y = "Bill depth (mm)", 136 | title = "Scatterplot of penguin bill dimensions", 137 | subtitle = "data = Palmer Penguins")+ 138 | theme_bw()+ 139 | 140 | scale_color_gradientn(colors = rev(soil_palette("redox2",5))) 141 | ``` 142 |
143 | 144 | 145 |
146 | Acknowledgments and Contributions 147 | 148 | Code structure was modelled after the [`PNWColors`](https://github.com/jakelawlor/PNWColors) and [`wesanderson`](https://github.com/karthik/wesanderson) packages. 149 | Contribute soil palettes in the [issues](https://github.com/kaizadp/soilpalettes/issues/6). 150 | 151 | 152 | -------------------------------------------------------------------------------- /R/soilpalettes.R: -------------------------------------------------------------------------------- 1 | # Soils Color Palette Package 2 | # These are color palettes for RStudio 3 | # inspired by soil profiles. 4 | 5 | # 1.Create the color palettes 6 | # :::::::::::::::::::::::::::::::::::::::::::::: 7 | #' Complete list of palettes 8 | #' 9 | #' Use \code{names(soil_palettes)} to view list of palette names. 10 | #' Currently: "alaquod" "durorthod" "eutrostox" "natrudoll" "paleustalf" "podzol" "rendoll" "vitrizerand" "bangor" "pywell" "crait" "redox" "redox2" "gley" 11 | #' 12 | #' @export 13 | soil_palettes <- list( 14 | alaquod = rbind(c('#321614', '#C8CED8', '#6E251E', '#B26535', '#E9B391'),c(3,4,1,2,5)), 15 | bangor = rbind(c('#564735', '#855A30', '#BA6C00', '#D4C394', '#A48D2F'),c(3,4,1,2,5)), 16 | durorthod = rbind(c('#2C0C00', '#803C15', '#C6782C', '#FFA91D', '#FFF3AD'),c(3,4,1,2,5)), 17 | paleustalf = rbind(c('#282828', '#69261F', '#BB1F0B', '#E58D43', '#EEC47B'),c(2,4,1,5,3)), 18 | # rendoll = rbind(c('#363636', '#78351D', '#B27529', '#FFD300', '#DCDCDA'),c(3,4,1,2,5)), 19 | rendoll = rbind(c('#363636', '#78351D', '#B27529', '#FFD300', '#DCDCDA'),c(3,1,5,2,4)), 20 | 21 | # redox = rbind(c('#BB281E', '#D56936', '#87D7EB', '#42B8D7', '#16879C'),c(1,3,5,2,4)), 22 | redox = rbind(c('#BB281E', '#D56936', '#87D7EB', '#42B8D7', '#16879C'),c(1,4,3,5,2)), 23 | podzol = rbind(c('#351821', '#9F2519', '#F65620', '#FFC87A', '#FBF2B5'),c(3,1,4,2,5)), 24 | eutrostox = rbind(c('#220901', '#621708', '#941B0C', '#BC3908', '#F6AA1C'),c(4,1,5,3,2)), 25 | pywell = rbind(c('#050308', '#0A0914', '#100E15', '#0B090D', '#0D0B16'),c(4,1,5,3,2)), 26 | 27 | natrudoll = rbind(c('#301311', '#824D28', '#C38D18', '#FFCD62', '#FFEBA8'),c(3,1,5,2,4)), 28 | vitrixerand = rbind(c('#281B27', '#723F27', '#9B6044', '#B5804C', '#FACD9A'),c(1,3,5,2,4)), 29 | 30 | crait = rbind(c('#F4F4F4', '#E9BBB8', '#DF837D', '#D44A41', '#C91105'),c(3,2,4,5,1)), 31 | gley = rbind(c('#BFBFBF', '#A1B7BF', '#80AEBE', '#58A6BE', '#009DBD'),c(1,3,5,2,4)), 32 | redox2 = rbind(c('#2E5894', '#FFE733', '#FFB200', '#EC5800', '#96001B'),c(1,4,3,5,2)) 33 | ) 34 | 35 | 36 | 37 | # 2. Palette builder function 38 | # :::::::::::::::::::::::::::::::::::::::::::::: 39 | 40 | #' Soil Palette Generator. 41 | #' 42 | #' This function builds palettes based on soil profiles. 43 | #' View photos for each palette \href{https://github.com/kaizadp/soilpalettes}{On Github}. 44 | #' 45 | #' @param name Name of the color palette. Options are \code{durorthod}, \code{rendoll}, \code{paleustalf}, 46 | #' \code{natrudoll}, \code{alaquod2}, \code{alaquod} 47 | #' @param n Number of colors in the palette. Palletes include 5 colors, which can be used discretely, 48 | #' or if more are desired, used as a gradient. If omitted, n = length of palette. 49 | #' @param type Usage of palette as "continuous" or "discrete". Continuous usage interpolates between colors to create 50 | #' a scale of values. If omitted, function assumes continuous if n > length of palette, and discrete if n < length of palette. 51 | #' @param direction (TODO) 52 | #' 53 | #' @return TODO 54 | #' @export 55 | #' 56 | #' @examples 57 | #' soil_palette("durorthod", n = 100, type = "continuous") 58 | #' soil_palette("durorthod", 3) 59 | #' soil_palette("durorthod", 50) 60 | soil_palette <- function(name, n, type = c("discrete", "continuous"), direction = 1) { 61 | stopifnot(is.character(name)) 62 | stopifnot(is.numeric(n)) 63 | stopifnot(is.character(name)) 64 | 65 | pal <- soil_palettes[[name]] 66 | 67 | 68 | if (is.null(pal)) { 69 | stop("Palette not found.") 70 | } 71 | 72 | if (missing(n)) { 73 | n <- length(pal[1, ]) 74 | } 75 | 76 | if (missing(type)) { 77 | if (n > length(pal[1, ])) { 78 | type <- "continuous" 79 | } 80 | else { 81 | type <- "discrete" 82 | } 83 | } 84 | type <- match.arg(type) 85 | 86 | if (type == "discrete" && n > length(pal[1, ])) { 87 | stop("Number of requested colors greater than what discrete palette can offer, \n use as continuous instead.") 88 | } 89 | 90 | if (abs(direction) != 1) { 91 | stop("direction must be 1 or -1") 92 | } 93 | 94 | if (direction == -1) { 95 | pal[1, ] <- rev(pal[1, ]) 96 | } 97 | 98 | out <- switch(type, 99 | continuous = grDevices::colorRampPalette(pal[1, ])(n), 100 | discrete = pal[1, ][pal[2, ] %in% c(1:n)], 101 | ) 102 | structure(out, class = "palette", name = name) 103 | } 104 | 105 | 106 | #' Palette Print Function 107 | #' 108 | #' @param x TODO 109 | #' @param ... TODO 110 | #' @importFrom graphics image par text rect 111 | #' @importFrom stats median 112 | #' @importFrom grDevices rgb 113 | #' @return TODO 114 | #' @export 115 | print.palette <- function(x, ...) { 116 | stopifnot(class(x) == "palette") 117 | 118 | n <- length(x) 119 | old <- par(mar = c(0.5, 0.5, 0.5, 0.5)) 120 | on.exit(par(old)) 121 | 122 | image(1:n, 1, as.matrix(1:n), 123 | col = x, 124 | ylab = "", xaxt = "n", yaxt = "n", bty = "n" 125 | ) 126 | 127 | rect(0, 0.9, n + 1, 1.1, col = rgb(1, 1, 1, 0.8), border = NA) 128 | text(median(1:n), 1, labels = attr(x, "name"), cex = 1, family = "sans") 129 | } 130 | --------------------------------------------------------------------------------