├── .Rbuildignore ├── .covrignore ├── .github ├── .gitignore └── workflows │ ├── R-CMD-check.yaml │ ├── lint.yaml │ ├── pkgdown.yaml │ ├── pr-commands.yaml │ └── test-coverage.yaml ├── .gitignore ├── .lintr ├── .pre-commit-config.yaml ├── CONTRIBUTING.md ├── DESCRIPTION ├── Makefile ├── NAMESPACE ├── NEWS.md ├── R ├── banking.R ├── base.R ├── calc.R ├── canva.R ├── clean.R ├── colorblind.R ├── economist.R ├── excel.R ├── few.R ├── fivethirtyeight.R ├── gdocs.R ├── geom-rangeframe.R ├── geom-tufteboxplot.R ├── ggthemes-package.R ├── ggthemes_data.R ├── hc.R ├── igray.R ├── pander.R ├── ptol.R ├── scales.R ├── shapes.R ├── show.R ├── solarized.R ├── stat-fivenumber.R ├── stata.R ├── tableau.R ├── theme-foundation.R ├── theme-map.R ├── theme-solid.R ├── tufte.R ├── utils.R └── wsj.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── codecov.yml ├── cran-comments.md ├── data-raw ├── build.R ├── canva_palette.R ├── clean-colors.R ├── excel │ ├── mtcars.csv │ ├── mtcars.ods │ └── mtcars.xlsx ├── excel_themes.R ├── libreoffice_palettes.R ├── stata │ └── examples.do └── theme-data │ ├── colorblind.yml │ ├── economist.yml │ ├── excel-themes.yml │ ├── excel.yml │ ├── few.yml │ ├── fivethirtyeight.yml │ ├── gdocs.yml │ ├── hc.yml │ ├── highcharts.yml │ ├── libreoffice.yml │ ├── manyeyes.yml │ ├── numbers-charts.yml │ ├── pault.yml │ ├── shapes.yml │ ├── solarized.yml │ ├── stata.yml │ ├── tableau-classic.xml │ ├── tableau-new.yml │ ├── tableau.yml │ └── wsj.yml ├── data ├── canva_palettes.rda └── ggthemes_data.rda ├── ggthemes.Rproj ├── inst ├── WORDLIST └── examples │ ├── ex-bank_slopes.R │ ├── ex-calc_pal.R │ ├── ex-calc_shape_pal.R │ ├── ex-canva_pal.R │ ├── ex-cleveland_shape_pal.R │ ├── ex-colorblind.R │ ├── ex-economist_pal.R │ ├── ex-excel_new_pal.R │ ├── ex-excel_pal.R │ ├── ex-few_pal.R │ ├── ex-few_shape_pal.R │ ├── ex-fivethirtyeight_pal.R │ ├── ex-gdocs_pal.R │ ├── ex-geom_rangeframe.R │ ├── ex-geom_tufteboxplot.R │ ├── ex-palette_pander.R │ ├── ex-ptol_pal.R │ ├── ex-scale_color_tableau.R │ ├── ex-scale_colour_excel_classic.R │ ├── ex-scale_colour_excel_new.R │ ├── ex-scale_colour_gradient2_tableau.R │ ├── ex-scale_colour_gradient_tableau.R │ ├── ex-scale_colour_ptol.R │ ├── ex-scale_linetype_stata.R │ ├── ex-scale_shape_stata.R │ ├── ex-scale_shape_tableau.R │ ├── ex-scale_shape_tremmel.R │ ├── ex-scale_solarized.R │ ├── ex-show_linetypes.R │ ├── ex-show_shapes.R │ ├── ex-solarized_pal.R │ ├── ex-stata_pal.R │ ├── ex-tableau_color_pal.R │ ├── ex-tableau_div_gradient_pal.R │ ├── ex-tableau_seq_gradient_pal.R │ ├── ex-tableau_shape_pal.R │ ├── ex-theme_base.R │ ├── ex-theme_calc.R │ ├── ex-theme_clean.R │ ├── ex-theme_economist.R │ ├── ex-theme_excel.R │ ├── ex-theme_excel_new.R │ ├── ex-theme_few.R │ ├── ex-theme_fivethirtyeight.R │ ├── ex-theme_gdocs.R │ ├── ex-theme_hc.R │ ├── ex-theme_igray.R │ ├── ex-theme_map.R │ ├── ex-theme_pander.R │ ├── ex-theme_par.R │ ├── ex-theme_solarized.R │ ├── ex-theme_solid.R │ ├── ex-theme_stata.R │ ├── ex-theme_tufte.R │ └── ex-theme_wsj.R ├── man ├── bank_slopes.Rd ├── calc_pal.Rd ├── calc_shape_pal.Rd ├── canva_pal.Rd ├── canva_palettes.Rd ├── circlefill_shape_pal.Rd ├── cleveland_shape_pal.Rd ├── colorblind.Rd ├── economist_pal.Rd ├── excel_new_pal.Rd ├── excel_pal.Rd ├── few_pal.Rd ├── few_shape_pal.Rd ├── figures │ ├── README-scale_color_tableau-1.png │ ├── README-scale_colorblind-1.png │ ├── README-theme_calc-1.png │ ├── README-theme_clean-1.png │ ├── README-theme_economist-1.png │ ├── README-theme_excel-1.png │ ├── README-theme_excel_new-1.png │ ├── README-theme_few-1.png │ ├── README-theme_fivethirtyeight-1.png │ ├── README-theme_igray-1.png │ ├── README-theme_par-1.png │ ├── README-theme_solarized-1.png │ ├── README-theme_solarized_dark-1.png │ ├── README-theme_solid-1.png │ ├── README-theme_stata-1.png │ └── README-theme_wsj-1.png ├── fivethirtyeight_pal.Rd ├── gdocs_pal.Rd ├── geom_rangeframe.Rd ├── geom_tufteboxplot.Rd ├── ggthemes-package.Rd ├── ggthemes_data.Rd ├── hc_pal.Rd ├── macros │ └── funclink.Rd ├── palette_pander.Rd ├── ptol_pal.Rd ├── range_breaks.Rd ├── scale_calc.Rd ├── scale_color_tableau.Rd ├── scale_colour_canva.Rd ├── scale_colour_gradient2_tableau.Rd ├── scale_colour_gradient_tableau.Rd ├── scale_economist.Rd ├── scale_excel.Rd ├── scale_excel_new.Rd ├── scale_few.Rd ├── scale_fivethirtyeight.Rd ├── scale_gdocs.Rd ├── scale_hc.Rd ├── scale_linetype_stata.Rd ├── scale_pander.Rd ├── scale_ptol.Rd ├── scale_shape_calc.Rd ├── scale_shape_circlefill.Rd ├── scale_shape_cleveland.Rd ├── scale_shape_few.Rd ├── scale_shape_stata.Rd ├── scale_shape_tableau.Rd ├── scale_shape_tremmel.Rd ├── scale_solarized.Rd ├── scale_stata.Rd ├── scale_wsj.Rd ├── show_linetypes.Rd ├── show_shapes.Rd ├── smart_digits.Rd ├── solarized_pal.Rd ├── solarized_rebase.Rd ├── stat_fivenumber.Rd ├── stata_linetype_pal.Rd ├── stata_pal.Rd ├── stata_shape_pal.Rd ├── tableau_color_pal.Rd ├── tableau_gradient_pal.Rd ├── tableau_shape_pal.Rd ├── theme_base.Rd ├── theme_calc.Rd ├── theme_clean.Rd ├── theme_economist.Rd ├── theme_excel.Rd ├── theme_excel_new.Rd ├── theme_few.Rd ├── theme_fivethirtyeight.Rd ├── theme_foundation.Rd ├── theme_gdocs.Rd ├── theme_hc.Rd ├── theme_igray.Rd ├── theme_map.Rd ├── theme_pander.Rd ├── theme_par.Rd ├── theme_solarized.Rd ├── theme_solid.Rd ├── theme_stata.Rd ├── theme_tufte.Rd ├── theme_wsj.Rd ├── tremmel_shape_pal.Rd └── wsj_pal.Rd ├── scripts └── style.R └── tests ├── figs ├── deps.txt └── few │ └── theme-few.svg ├── spelling.R ├── testthat.R └── testthat ├── _snaps ├── few │ └── theme-few.svg └── shapes.md ├── helper-utils.R ├── helper-vdiffr.R ├── test-banking.R ├── test-base.R ├── test-calc.R ├── test-canva.R ├── test-colorblind.R ├── test-economist.R ├── test-excel.R ├── test-few.R ├── test-fivethirtyeight.R ├── test-gdocs.R ├── test-geom-rangeframe.R ├── test-hc.R ├── test-igray.R ├── test-pander.R ├── test-ptol.R ├── test-shapes.R ├── test-show.R ├── test-solarized.R ├── test-stat_fivenumber.R ├── test-stata.R ├── test-tableau.R ├── test-theme_map.R ├── test-theme_solid.R ├── test-tufte.R ├── test-tufteboxplot.R └── test-wsj_pal.R /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^CRAN-RELEASE$ 2 | ^\.gitignore$ 3 | ^README\.(R?md|html)$ 4 | ^figure$ 5 | ^\.Rhistory$ 6 | ^stata$ 7 | ^Makefile$ 8 | ^make-README\.R$ 9 | ^cran-comments\.md$ 10 | ^.*\.Rproj$ 11 | ^\.Rproj\.user$ 12 | ^data-raw$ 13 | ^\.lintr$ 14 | ^revdep$ 15 | ^_pkgdown\.yml$ 16 | ^docs$ 17 | ^codecov\.yml$ 18 | ^\.covrignore$ 19 | ^appveyor\.yml$ 20 | ^\.github$ 21 | ^CONTRIBUTING.*$ 22 | ^\.pre-commit-config\.yaml$ 23 | ^CRAN-SUBMISSION$ 24 | ^scripts$ 25 | ^pkgdown$ 26 | -------------------------------------------------------------------------------- /.covrignore: -------------------------------------------------------------------------------- 1 | R/utils.R 2 | -------------------------------------------------------------------------------- /.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 | 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: 'release'} 22 | - {os: windows-latest, r: 'release'} 23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 24 | - {os: ubuntu-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'oldrel-1'} 26 | 27 | env: 28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 29 | R_KEEP_PKG_SOURCE: yes 30 | 31 | steps: 32 | - uses: actions/checkout@v4 33 | 34 | - uses: r-lib/actions/setup-pandoc@v2 35 | 36 | - uses: r-lib/actions/setup-r@v2 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | http-user-agent: ${{ matrix.config.http-user-agent }} 40 | use-public-rspm: true 41 | 42 | - uses: r-lib/actions/setup-r-dependencies@v2 43 | with: 44 | extra-packages: any::rcmdcheck 45 | needs: check 46 | 47 | - uses: r-lib/actions/check-r-package@v2 48 | with: 49 | upload-snapshots: true 50 | -------------------------------------------------------------------------------- /.github/workflows/lint.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: lint 10 | 11 | jobs: 12 | lint: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - uses: r-lib/actions/setup-r@v2 20 | with: 21 | use-public-rspm: true 22 | 23 | - uses: r-lib/actions/setup-r-dependencies@v2 24 | with: 25 | extra-packages: any::lintr, local::. 26 | needs: lint 27 | 28 | - name: Lint 29 | run: lintr::lint_package() 30 | shell: Rscript {0} 31 | env: 32 | LINTR_ERROR_ON_LINT: true 33 | -------------------------------------------------------------------------------- /.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 | jobs: 15 | pkgdown: 16 | runs-on: ubuntu-latest 17 | # Only restrict concurrency for non-PR jobs 18 | concurrency: 19 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 20 | env: 21 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 22 | permissions: 23 | contents: write 24 | steps: 25 | - uses: actions/checkout@v4 26 | 27 | - uses: r-lib/actions/setup-pandoc@v2 28 | 29 | - uses: r-lib/actions/setup-r@v2 30 | with: 31 | use-public-rspm: true 32 | 33 | - uses: r-lib/actions/setup-r-dependencies@v2 34 | with: 35 | extra-packages: any::pkgdown, local::. 36 | needs: website 37 | 38 | - name: Build site 39 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 40 | shell: Rscript {0} 41 | 42 | - name: Deploy to GitHub pages 🚀 43 | if: github.event_name != 'pull_request' 44 | uses: JamesIves/github-pages-deploy-action@v4.5.0 45 | with: 46 | clean: false 47 | branch: gh-pages 48 | folder: docs 49 | -------------------------------------------------------------------------------- /.github/workflows/pr-commands.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 | issue_comment: 5 | types: [created] 6 | 7 | name: Commands 8 | 9 | jobs: 10 | document: 11 | if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} 12 | name: document 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | steps: 17 | - uses: actions/checkout@v4 18 | 19 | - uses: r-lib/actions/pr-fetch@v2 20 | with: 21 | repo-token: ${{ secrets.GITHUB_TOKEN }} 22 | 23 | - uses: r-lib/actions/setup-r@v2 24 | with: 25 | use-public-rspm: true 26 | 27 | - uses: r-lib/actions/setup-r-dependencies@v2 28 | with: 29 | extra-packages: any::roxygen2 30 | needs: pr-document 31 | 32 | - name: Document 33 | run: roxygen2::roxygenise() 34 | shell: Rscript {0} 35 | 36 | - name: commit 37 | run: | 38 | git config --local user.name "$GITHUB_ACTOR" 39 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 40 | git add man/\* NAMESPACE 41 | git commit -m 'Document' 42 | 43 | - uses: r-lib/actions/pr-push@v2 44 | with: 45 | repo-token: ${{ secrets.GITHUB_TOKEN }} 46 | 47 | style: 48 | if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} 49 | name: style 50 | runs-on: ubuntu-latest 51 | env: 52 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 53 | steps: 54 | - uses: actions/checkout@v4 55 | 56 | - uses: r-lib/actions/pr-fetch@v2 57 | with: 58 | repo-token: ${{ secrets.GITHUB_TOKEN }} 59 | 60 | - uses: r-lib/actions/setup-r@v2 61 | 62 | - name: Install dependencies 63 | run: install.packages("styler") 64 | shell: Rscript {0} 65 | 66 | - name: Style 67 | run: styler::style_pkg() 68 | shell: Rscript {0} 69 | 70 | - name: commit 71 | run: | 72 | git config --local user.name "$GITHUB_ACTOR" 73 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 74 | git add \*.R 75 | git commit -m 'Style' 76 | 77 | - uses: r-lib/actions/pr-push@v2 78 | with: 79 | repo-token: ${{ secrets.GITHUB_TOKEN }} 80 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.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: test-coverage 10 | 11 | jobs: 12 | test-coverage: 13 | runs-on: ubuntu-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | 20 | - uses: r-lib/actions/setup-r@v2 21 | with: 22 | use-public-rspm: true 23 | 24 | - uses: r-lib/actions/setup-r-dependencies@v2 25 | with: 26 | extra-packages: any::covr 27 | needs: coverage 28 | 29 | - name: Test coverage 30 | run: | 31 | covr::codecov( 32 | quiet = FALSE, 33 | clean = FALSE, 34 | install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") 35 | ) 36 | shell: Rscript {0} 37 | 38 | - name: Show testthat output 39 | if: always() 40 | run: | 41 | ## -------------------------------------------------------------------- 42 | find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true 43 | shell: bash 44 | 45 | - name: Upload test results 46 | if: failure() 47 | uses: actions/upload-artifact@v4 48 | with: 49 | name: coverage-test-failures 50 | path: ${{ runner.temp }}/package 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | stata/*.png 2 | .Rproj.user 3 | inst/doc 4 | .Rhistory 5 | README.html 6 | revdep 7 | *.DS_Store 8 | docs 9 | -------------------------------------------------------------------------------- /.lintr: -------------------------------------------------------------------------------- 1 | linters: linters_with_defaults( 2 | line_length_linter(120), 3 | commented_code_linter = NULL, 4 | indentation_linter = NULL 5 | ) 6 | encoding: "UTF-8" 7 | exclusions: list( 8 | "./inst/exampels/ex-few_shape_pal.R", 9 | "./inst/examples/ex-calc_shape_pal.R", 10 | "./inst/examples/ex-cleveland_shape_pal.R", 11 | "./inst/examples/ex-few_shape_pal.R", 12 | "./inst/examples/ex-palette_pander.R", 13 | "./inst/examples/ex-scale_shape_stata.R", 14 | "./inst/examples/ex-scale_shape_tableau.R", 15 | "./inst/examples/ex-tableau_shape_pal.R", 16 | "./inst/examples/ex-tableau_shape_pal.R", 17 | "./inst/examples/ex-theme_calc.R", 18 | "./inst/examples/ex-theme_economist.R" 19 | ) 20 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: 'v4.5.0' 4 | hooks: 5 | - id: check-yaml 6 | - id: 'no-commit-to-branch' 7 | args: ['--branch', 'main'] 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | To Contribute a new theme to ggthemes: 2 | 3 | 1. fork the respository 4 | 2. clone onto your personal machine 5 | 3. add the .R file containing functions for creating your theme to ggthemes/tree/main/R 6 | 4. add an image of your theme using mtcars to ggthemes/tree/main/figure 7 | 5. update the README to include a sample image of your theme 8 | 6. push updates 9 | 7. create pull request to include new theme 10 | 11 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: ggthemes 2 | Version: 5.1.0.9000 3 | Title: Extra Themes, Scales and Geoms for 'ggplot2' 4 | Authors@R: c(person("Jeffrey B.", "Arnold", role = c("aut", "cre"), 5 | email = "jeffrey.arnold@gmail.com", 6 | comment = ""), 7 | person("Gergely", "Daroczi", role = "ctb"), 8 | person("Bo", "Werth", role = "ctb"), 9 | person("Brian", "Weitzner", role = "ctb"), 10 | person("Joshua", "Kunst", role = "ctb"), 11 | person("Baptise", "Auguie", role = "ctb"), 12 | person("Bob", "Rudis", role = "ctb"), 13 | person("Hadley", "Wickham", role = c("ctb"), 14 | comment = "Code from the ggplot2 package."), 15 | person("Justin", "Talbot", role = "ctb", 16 | comment = "Code from the labeling package"), 17 | person("Joshua", "London", role = "ctb")) 18 | Depends: 19 | R (>= 3.3.0) 20 | Imports: 21 | ggplot2 (>= 3.0.0), 22 | graphics, 23 | grid, 24 | lifecycle, 25 | methods, 26 | purrr, 27 | scales, 28 | stringr, 29 | tibble 30 | Suggests: 31 | dplyr, 32 | covr, 33 | extrafont, 34 | glue, 35 | knitr, 36 | lattice, 37 | lintr, 38 | maps, 39 | mapproj, 40 | pander, 41 | quantreg, 42 | rlang, 43 | rmarkdown, 44 | spelling, 45 | testthat (>= 3.2.0), 46 | tidyr, 47 | vdiffr, 48 | withr 49 | Description: Some extra themes, geoms, and scales for 'ggplot2'. 50 | Provides 'ggplot2' themes and scales that replicate the look of plots 51 | by Edward Tufte, Stephen Few, 'Fivethirtyeight', 'The Economist', 'Stata', 52 | 'Excel', and 'The Wall Street Journal', among others. 53 | Provides 'geoms' for Tufte's box plot and range frame. 54 | License: GPL-2 55 | URL: https://jrnold.github.io/ggthemes/, https://github.com/jrnold/ggthemes, http://jrnold.github.io/ggthemes/ 56 | BugReports: https://github.com/jrnold/ggthemes/issues 57 | RoxygenNote: 7.3.1 58 | LazyData: true 59 | Language: en-US 60 | Encoding: UTF-8 61 | Config/testthat/edition: 3 62 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | RSCRIPT = Rscript 2 | 3 | all: build 4 | 5 | .PHONY: build 6 | build: docs site data 7 | 8 | .PHONY: test 9 | test: 10 | $(RSCRIPT) -e 'devtools::check()' 11 | 12 | .PHONY: docs 13 | docs: 14 | $(RSCRIPT) -e 'devtools::document()' 15 | 16 | .PHONY: site 17 | site: 18 | $(RSCRIPT) -e 'pkgdown::build_site()' 19 | 20 | .PHONY: data 21 | data: 22 | $(RSCRIPT) data-raw/build.R 23 | 24 | .PHONY: style 25 | style: 26 | $(RSCRIPT) scripts/style.R 27 | 28 | .PHONY: lint 29 | lint: 30 | $(RSCRIPT) -e 'devtools::lint()' 31 | 32 | README.md: README.Rmd 33 | $(RSCRIPT) -e 'knitr::knit("$<", output = "$@", quiet = TRUE)' 34 | 35 | -------------------------------------------------------------------------------- /R/canva.R: -------------------------------------------------------------------------------- 1 | # nolint start 2 | #' 150 Color Palettes from Canva 3 | #' 4 | #' 150 four-color palettes by the 5 | #' \href{https://www.canva.com/learn/}{canva.com} design school. 6 | #' These palettes were derived from photos and "impactful websites". 7 | #' 8 | #' @format A named \code{list} of character vector. 9 | #' The names are the palette names. The values of the character vectors 10 | #' are hex colors, e.g. \code{"#f98866"}. 11 | #' 12 | #' @references 13 | #' \itemize{ 14 | #' \item{Janie Kliever, \href{https://www.canva.com/learn/100-color-combinations/}{100 Brilliant Color Combinations and How to Apply Them to Your Designs}, 15 | #' \emph{Canva.com}, June 20, 2015.} 16 | #' \item{Mary Stribley, \href{https://www.canva.com/learn/website-color-schemes/}{Website Color Schemes: The Palettes of 50 Visually Impactful Websites to Inspire You}, 17 | #' \emph{Canva.com}, January 26, 2016.} 18 | #' \item{Schwabish, Jonathan. 19 | #' \href{https://policyviz.com/2017/01/12/150-color-palettes-for-excel/}{150+ Color Palettes for Excel}, 20 | #' \emph{PolicyViz}, January 12, 2017.} 21 | #' } 22 | #' @example inst/examples/ex-canva_pal.R 23 | "canva_palettes" 24 | # nolint end 25 | 26 | #' Canva.com color palettes 27 | #' 28 | #' 150+ color palettes from canva.com. See \code{\link{canva_palettes}()}. 29 | #' 30 | #' @param palette Palette name. See the names of \code{\link{canva_palettes}()} 31 | #' for valid names. 32 | #' @return A function that takes a single value, the number of colors to use. 33 | #' @export 34 | #' @example inst/examples/ex-canva_pal.R 35 | canva_pal <- function(palette = "Fresh and bright") { 36 | if (!palette %in% names(ggthemes::canva_palettes)) { 37 | stop("Palette ", sQuote(palette), " not a valid name.", call. = FALSE) 38 | } 39 | manual_pal(unname(ggthemes::canva_palettes[[palette]])) 40 | } 41 | 42 | #' Discrete color scale using canva.com color palettes 43 | #' 44 | #' Color scale for canva.com color palettes described in 45 | #' \code{\link{canva_palettes}()}. 46 | #' 47 | #' @param ... Arguments passed to \code{\link{discrete_scale}()}. 48 | #' @inheritParams canva_pal 49 | #' @export 50 | scale_colour_canva <- function(..., palette = "Fresh and bright") { 51 | discrete_scale("colour", "canva", canva_pal(palette), ...) 52 | } 53 | 54 | #' @export 55 | #' @rdname scale_colour_canva 56 | scale_color_canva <- scale_colour_canva 57 | 58 | #' @export 59 | #' @rdname scale_colour_canva 60 | scale_fill_canva <- function(..., palette = "Fresh and bright") { 61 | discrete_scale("fill", "canva", canva_pal(palette), ...) 62 | } 63 | -------------------------------------------------------------------------------- /R/clean.R: -------------------------------------------------------------------------------- 1 | #' @title Clean ggplot theme 2 | #' 3 | #' @description Clean ggplot theme with no panel background, black axis lines 4 | #' and grey fill colour for chart elements. 5 | #' 6 | #' @author Konrad Zdeb \email{name.surname@@me.com} 7 | #' 8 | #' @param base_size Base font size. 9 | #' @param base_family Base font family. 10 | #' 11 | #' @family themes 12 | #' @export 13 | #' 14 | #' @example inst/examples/ex-theme_clean.R 15 | theme_clean <- function(base_size = 12, 16 | base_family = "sans") { 17 | ( 18 | theme_foundation( 19 | base_size = base_size, 20 | base_family = base_family 21 | ) + theme( 22 | axis.line.x = element_line( 23 | colour = "black", 24 | size = 0.5, 25 | linetype = "solid" 26 | ), 27 | axis.line.y = element_line( 28 | colour = "black", 29 | size = 0.5, 30 | linetype = "solid" 31 | ), 32 | axis.text = element_text(size = ceiling(base_size * 0.7), colour = "black"), 33 | axis.title = element_text(size = ceiling(base_size * 0.8)), 34 | panel.grid.minor = element_blank(), 35 | panel.grid.major.y = element_line(colour = "gray", linetype = "dotted"), 36 | panel.grid.major.x = element_blank(), 37 | panel.background = element_blank(), 38 | panel.border = element_blank(), 39 | strip.background = element_rect(linetype = 0), 40 | strip.text = element_text(), 41 | strip.text.x = element_text(vjust = 0.5), 42 | strip.text.y = element_text(angle = -90), 43 | legend.text = element_text(size = ceiling(base_size * 0.9), family = "sans"), 44 | legend.title = element_text( 45 | size = base_size, 46 | face = "bold", 47 | family = "sans" 48 | ), 49 | legend.position = "right", 50 | legend.key = element_rect(fill = "white", colour = NA), 51 | legend.background = element_rect(colour = "black"), 52 | plot.background = element_rect(colour = "black"), 53 | plot.title = element_text(size = ceiling(base_size * 1.1), face = "bold"), 54 | plot.subtitle = element_text(size = ceiling(base_size * 1.05)) 55 | ) 56 | ) 57 | } 58 | -------------------------------------------------------------------------------- /R/colorblind.R: -------------------------------------------------------------------------------- 1 | #' Colorblind Color Palette (Discrete) and Scales 2 | #' 3 | #' An eight-color colorblind safe qualitative discrete palette. 4 | #' 5 | #' @rdname colorblind 6 | #' @references 7 | #' Chang, W. "\href{http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/#a-colorblind-friendly-palette}{Cookbook for R}" 8 | #' 9 | #' \verb{https://jfly.iam.u-tokyo.ac.jp/color} 10 | #' 11 | #' @export 12 | #' @inheritParams ggplot2::scale_colour_hue 13 | #' @family colour 14 | #' @seealso The \pkg{dichromat} package, \code{\link[scales]{dichromat_pal}()}, 15 | #' and \code{\link{scale_color_tableau}()} for other colorblind palettes. 16 | #' @example inst/examples/ex-colorblind.R 17 | colorblind_pal <- function() { 18 | values <- unname(ggthemes::ggthemes_data[["colorblind"]][["value"]]) 19 | f <- manual_pal(values) 20 | attr(f, "max_n") <- length(values) 21 | f 22 | } 23 | 24 | #' @rdname colorblind 25 | #' @export 26 | scale_colour_colorblind <- function(...) { 27 | discrete_scale("colour", "colorblind", colorblind_pal(), ...) 28 | } 29 | 30 | #' @rdname colorblind 31 | #' @export 32 | scale_color_colorblind <- scale_colour_colorblind 33 | 34 | #' @rdname colorblind 35 | #' @export 36 | scale_fill_colorblind <- function(...) { 37 | discrete_scale("fill", "colorblind", colorblind_pal(), ...) 38 | } 39 | -------------------------------------------------------------------------------- /R/fivethirtyeight.R: -------------------------------------------------------------------------------- 1 | #' Theme inspired by FiveThirtyEight plots 2 | #' 3 | #' Theme inspired by the plots from FiveThirtyEight.com. 4 | #' 5 | #' @inheritParams ggplot2::theme_grey 6 | #' @family themes fivethirtyeight 7 | #' @export 8 | #' @example inst/examples/ex-theme_fivethirtyeight.R 9 | #' @importFrom grid unit 10 | theme_fivethirtyeight <- function(base_size = 12, base_family = "sans") { 11 | colors <- deframe(ggthemes::ggthemes_data[["fivethirtyeight"]]) 12 | (theme_foundation(base_size = base_size, base_family = base_family) 13 | + theme( 14 | line = element_line(colour = "black"), 15 | rect = element_rect( 16 | fill = colors["Light Gray"], 17 | linetype = 0, colour = NA 18 | ), 19 | text = element_text(colour = colors["Dark Gray"]), 20 | axis.title = element_blank(), 21 | axis.text = element_text(), 22 | axis.ticks = element_blank(), 23 | axis.line = element_blank(), 24 | legend.background = element_rect(), 25 | legend.position = "bottom", 26 | legend.direction = "horizontal", 27 | legend.box = "vertical", 28 | panel.grid = element_line(colour = NULL), 29 | panel.grid.major = 30 | element_line(colour = colors["Medium Gray"]), 31 | panel.grid.minor = element_blank(), 32 | # unfortunately, can't mimic subtitles TODO! 33 | plot.title = element_text(hjust = 0, size = rel(1.5), face = "bold"), 34 | plot.margin = unit(c(1, 1, 1, 1), "lines"), 35 | strip.background = element_rect() 36 | )) 37 | } 38 | 39 | #' FiveThirtyEight color palette 40 | #' 41 | #' The standard three-color FiveThirtyEight palette for line plots comprises 42 | #' blue, red, and green. 43 | #' 44 | #' @family colour fivethirtyeight 45 | #' @export 46 | #' @example inst/examples/ex-fivethirtyeight_pal.R 47 | fivethirtyeight_pal <- function() { 48 | colors <- deframe(ggthemes::ggthemes_data[["fivethirtyeight"]]) 49 | values <- unname(colors[c("Blue", "Red", "Green")]) 50 | max_n <- length(values) 51 | f <- manual_pal(values) 52 | attr(f, "max_n") <- max_n 53 | f 54 | } 55 | 56 | #' FiveThirtyEight color scales 57 | #' 58 | #' Color scales using the colors in the FiveThirtyEight graphics. 59 | #' 60 | #' @inheritParams ggplot2::scale_colour_hue 61 | #' @family colour fivethirtyeight 62 | #' @rdname scale_fivethirtyeight 63 | #' @seealso \code{\link{theme_fivethirtyeight}()} for examples. 64 | #' @export 65 | scale_colour_fivethirtyeight <- function(...) { 66 | discrete_scale("colour", "economist", fivethirtyeight_pal(), ...) 67 | } 68 | 69 | #' @rdname scale_fivethirtyeight 70 | #' @export 71 | scale_color_fivethirtyeight <- scale_colour_fivethirtyeight 72 | 73 | #' @rdname scale_fivethirtyeight 74 | #' @export 75 | scale_fill_fivethirtyeight <- function(...) { 76 | discrete_scale("fill", "economist", fivethirtyeight_pal(), ...) 77 | } 78 | -------------------------------------------------------------------------------- /R/ggthemes-package.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | "_PACKAGE" 3 | 4 | #' @importFrom ggplot2 ggplot theme ggproto aes draw_key_path 5 | #' @importFrom grid grobTree grobName gTree gList segmentsGrob gpar 6 | #' @importFrom scales manual_pal div_gradient_pal seq_gradient_pal 7 | #' @importFrom graphics abline axis text points 8 | #' @importFrom methods hasArg as 9 | #' @importFrom graphics par 10 | NULL 11 | 12 | globalVariables(".data") 13 | -------------------------------------------------------------------------------- /R/ggthemes_data.R: -------------------------------------------------------------------------------- 1 | #' Palette and theme data 2 | #' 3 | #' The \code{ggthemes} environment contains various values used in 4 | #' themes and palettes. This is undocumented and subject to change. 5 | #' 6 | #' @format A \code{list} object. 7 | "ggthemes_data" 8 | -------------------------------------------------------------------------------- /R/igray.R: -------------------------------------------------------------------------------- 1 | #' Inverse gray theme 2 | #' 3 | #' Theme with white panel and gray background. 4 | #' 5 | #' @section Details: 6 | #' 7 | #' This theme inverts the colors in the \code{\link[ggplot2]{theme_gray}()}, a 8 | #' white panel and a light gray area around it. This keeps a white 9 | #' background for the color scales like \code{\link[ggplot2]{theme_bw}()}. But 10 | #' by using a gray background, the plot is closer to the 11 | #' typographical color of the document, which is the motivation for 12 | #' using a gray panel in \code{\link[ggplot2]{theme_gray}()}. This is 13 | #' similar to the style of plots in Stata and Tableau. 14 | #' 15 | #' @inheritParams ggplot2::theme_grey 16 | #' @export 17 | #' @family themes 18 | #' @seealso \code{\link[ggplot2]{theme_gray}()}, 19 | #' \code{\link[ggplot2]{theme_bw}()} 20 | #' @example inst/examples/ex-theme_igray.R 21 | #' @importFrom ggplot2 theme_gray 22 | theme_igray <- function(base_size = 12, base_family = "") { 23 | (theme_gray(base_size = base_size, base_family = base_family) + 24 | theme( 25 | rect = element_rect(fill = "gray90"), 26 | legend.key = element_rect(fill = "white"), 27 | panel.background = element_rect(fill = "white"), 28 | panel.grid.major = element_line(colour = "gray90"), 29 | plot.background = element_rect(fill = "gray90") 30 | )) 31 | } 32 | -------------------------------------------------------------------------------- /R/ptol.R: -------------------------------------------------------------------------------- 1 | #' Color Palettes from Paul Tol's "Colour Schemes" 2 | #' 3 | #' Qualitative color palettes from Paul Tol, 4 | #' \href{https://personal.sron.nl/~pault/}{"Colour Schemes"}. 5 | #' 6 | #' Incorporation of the palette into an R package was originally inspired by 7 | #' Peter Carl's [Paul Tol 21 Gun Salute](https://tradeblotter.wordpress.com/2013/02/28/the-paul-tol-21-color-salute/) 8 | #' 9 | #' @export 10 | #' @family colour ptol 11 | #' @references 12 | #' Paul Tol. 2012. "Colour Schemes." SRON Technical Note, SRON/EPS/TN/09-002. 13 | #' \url{https://personal.sron.nl/~pault/data/colourschemes.pdf} 14 | #' @example inst/examples/ex-ptol_pal.R 15 | ptol_pal <- function() { 16 | colors <- ggthemes::ggthemes_data[["ptol"]][["qualitative"]] 17 | max_n <- length(colors) 18 | f <- function(n) { 19 | check_pal_n(n, max_n) 20 | colors[[n]] 21 | } 22 | attr(f, "max_n") <- max_n 23 | f 24 | } 25 | 26 | #' Color Scales from Paul Tol's "Colour Schemes 27 | #' 28 | #' See \code{\link{ptol_pal}()}. These palettes support up to 12 values. 29 | #' 30 | #' @inheritParams ggplot2::scale_colour_hue 31 | #' @inheritParams ptol_pal 32 | #' @family colour ptol 33 | #' @rdname scale_ptol 34 | #' @export 35 | #' @example inst/examples/ex-scale_colour_ptol.R 36 | scale_colour_ptol <- function(...) { 37 | discrete_scale("colour", "ptol", ptol_pal(), ...) 38 | } 39 | 40 | #' @export 41 | #' @rdname scale_ptol 42 | scale_color_ptol <- scale_colour_ptol 43 | 44 | #' @export 45 | #' @rdname scale_ptol 46 | scale_fill_ptol <- function(...) { 47 | discrete_scale("fill", "ptol", ptol_pal(), ...) 48 | } 49 | -------------------------------------------------------------------------------- /R/show.R: -------------------------------------------------------------------------------- 1 | #' Show shapes 2 | #' 3 | #' A quick and dirty way to show shapes. 4 | #' 5 | #' @export 6 | #' @param shapes A numeric or character vector of shapes. See 7 | #' \code{\link[graphics]{par}()}. 8 | #' @param labels Include the plotting character value of the symbol. 9 | #' @seealso \code{\link[scales]{show_col}()}, \code{\link{show_linetypes}()} 10 | #' @return This function called for the side effect of creating a plot. 11 | #' It returns \code{shapes}. 12 | #' @example inst/examples/ex-show_shapes.R 13 | show_shapes <- function(shapes, labels = TRUE) { 14 | n <- length(shapes) 15 | ncol <- ceiling(sqrt(n)) 16 | nrow <- ceiling(n / ncol) 17 | x <- c(shapes, rep(NA, nrow * ncol - length(shapes))) 18 | x <- matrix(x, ncol = ncol, byrow = TRUE) 19 | x <- x[rev(seq_len(nrow(x))), ] 20 | plot(0, 0, 21 | xlim = c(1, ncol(x)), ylim = c(1, nrow(x)), type = "n", 22 | xlab = "", ylab = "", axes = FALSE 23 | ) 24 | for (i in seq_len(ncol(x))) { 25 | for (j in seq_len(nrow(x))) { 26 | points(i, j, pch = x[j, i]) 27 | if (labels) { 28 | text(i, j, x[j, i], pos = 1, col = "gray70") 29 | } 30 | } 31 | } 32 | invisible(shapes) 33 | } 34 | 35 | #' Show linetypes 36 | #' 37 | #' A quick and dirty way to show linetypes. 38 | #' 39 | #' @export 40 | #' @param linetypes A character vector of linetypes. See 41 | #' \code{\link{par}()}. 42 | #' @param labels Label each line with its linetype (lty) value. 43 | #' 44 | #' @seealso \code{\link[scales]{show_col}()}, \code{\link{show_linetypes}()} 45 | #' 46 | #' @example inst/examples/ex-show_linetypes.R 47 | #' @return This function called for the side effect of creating a plot. 48 | #' It returns \code{linetypes}. 49 | #' @importFrom graphics plot 50 | show_linetypes <- function(linetypes, labels = TRUE) { 51 | n <- length(linetypes) 52 | plot(0, 0, 53 | xlim = c(0, 1), ylim = c(n, 1), type = "n", xlab = "", 54 | ylab = "", axes = FALSE 55 | ) 56 | for (i in seq_along(linetypes)) { 57 | abline(h = i, lty = linetypes[i]) 58 | } 59 | if (labels) { 60 | axis(side = 2, at = seq_len(n), tick = FALSE, labels = linetypes, las = 2) 61 | } else { 62 | axis(side = 2, at = seq_len(n), tick = FALSE, labels = seq_len(n), las = 2) 63 | } 64 | invisible(linetypes) 65 | } 66 | -------------------------------------------------------------------------------- /R/theme-foundation.R: -------------------------------------------------------------------------------- 1 | #' Foundation Theme 2 | #' 3 | #' This theme is designed to be a foundation from which to build new 4 | #' themes, and not meant to be used directly. \code{theme_foundation()} 5 | #' is a complete theme with only minimal number of elements defined. 6 | #' It is easier to create new themes by extending this one rather 7 | #' than \code{\link[ggplot2]{theme_gray}()} or \code{\link[ggplot2]{theme_bw}()}, 8 | #' because those themes define elements deep in the hierarchy. 9 | #' 10 | #' This theme takes \code{\link[ggplot2]{theme_gray}()} and sets all 11 | #' \code{colour} and \code{fill} values to \code{NULL}, except for the top-level 12 | #' elements (\code{line}, \code{rect}, and \code{title}), which have 13 | #' \code{colour = "black"}, and \code{fill = "white"}. This leaves the spacing 14 | #' and-non colour defaults of the default \pkg{ggplot2} themes in place. 15 | #' 16 | #' @inheritParams ggplot2::theme_grey 17 | #' 18 | #' @family themes 19 | #' @export 20 | #' @importFrom ggplot2 theme_grey 21 | theme_foundation <- function(base_size = 12, base_family = "") { 22 | thm <- theme_grey(base_size = base_size, base_family = base_family) 23 | for (i in names(thm)) { 24 | if ("colour" %in% names(thm[[i]])) { 25 | thm[[i]]["colour"] <- list(NULL) 26 | } 27 | if ("fill" %in% names(thm[[i]])) { 28 | thm[[i]]["fill"] <- list(NULL) 29 | } 30 | } 31 | thm + theme( 32 | panel.border = element_rect(fill = NA), 33 | legend.background = element_rect(colour = NA), 34 | line = element_line(colour = "black"), 35 | rect = element_rect(fill = "white", colour = "black"), 36 | text = element_text(colour = "black") 37 | ) 38 | } 39 | -------------------------------------------------------------------------------- /R/theme-map.R: -------------------------------------------------------------------------------- 1 | #' Clean theme for maps 2 | #' 3 | #' A clean theme that is good for displaying maps from 4 | #' \code{\link[ggplot2]{geom_map}()}. 5 | #' 6 | #' @inheritParams ggplot2::theme_grey 7 | #' @example inst/examples/ex-theme_map.R 8 | #' @export 9 | #' @importFrom ggplot2 %+replace% 10 | theme_map <- function(base_size = 9, base_family = "") { 11 | theme_bw(base_size = base_size, base_family = base_family) %+replace% 12 | theme( 13 | axis.line = element_blank(), 14 | axis.text = element_blank(), 15 | axis.ticks = element_blank(), 16 | axis.title = element_blank(), 17 | panel.background = element_blank(), 18 | panel.border = element_blank(), 19 | panel.grid = element_blank(), 20 | panel.spacing = unit(0, "lines"), 21 | plot.background = element_blank(), 22 | legend.justification = c(0, 0), 23 | legend.position = c(0, 0) 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /R/theme-solid.R: -------------------------------------------------------------------------------- 1 | #' Theme with nothing other than a background color 2 | #' 3 | #' Theme that removes all non-geom elements (lines, text, etc), 4 | #' This theme is when only the geometric objects are desired. 5 | #' 6 | #' @param base_size Base font size. 7 | #' @param base_family Ignored, kept for consistency with \code{\link{theme}()}. 8 | #' @param fill Background color of the plot. 9 | #' @family themes 10 | #' @example inst/examples/ex-theme_solid.R 11 | #' @export 12 | theme_solid <- function(base_size = 12, base_family = "", fill = NA) { 13 | theme_foundation() + 14 | theme( 15 | line = element_blank(), 16 | text = element_blank(), 17 | rect = element_rect( 18 | fill = fill, linewidth = base_size, colour = NA, 19 | linetype = 0 20 | ) 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /R/tufte.R: -------------------------------------------------------------------------------- 1 | #' Tufte Maximal Data, Minimal Ink Theme 2 | #' 3 | #' Theme based on Chapter 6 'Data-Ink Maximization and Graphical 4 | #' Design' of Edward Tufte *The Visual Display of Quantitative 5 | #' Information*. No border, no axis lines, no grids. This theme works 6 | #' best in combination with \code{\link{geom_rug}()} or 7 | #' \code{\link{geom_rangeframe}()}. 8 | #' 9 | #' @note 10 | #' The default font family is set to 'serif' as he uses serif fonts 11 | #' for labels in 'The Visual Display of Quantitative Information'. 12 | #' The serif font used by Tufte in his books is a variant of Bembo, 13 | #' while the sans serif font is Gill Sans. If these fonts are 14 | #' installed on your system, then you can use them with the package 15 | #' \bold{extrafont}. 16 | #' 17 | #' @inheritParams ggplot2::theme_grey 18 | #' @param ticks \code{logical} Show axis ticks? 19 | #' 20 | #' @references Tufte, Edward R. (2001) The Visual Display of 21 | #' Quantitative Information, Chapter 6. 22 | #' 23 | #' @family themes tufte 24 | #' @example inst/examples/ex-theme_tufte.R 25 | #' @export 26 | #' @importFrom ggplot2 theme_bw 27 | theme_tufte <- function(base_size = 11, base_family = "serif", ticks = TRUE) { 28 | ## TODO: start with theme_minimal 29 | ret <- theme_bw(base_family = base_family, base_size = base_size) + 30 | theme( 31 | legend.background = element_blank(), 32 | legend.key = element_blank(), 33 | panel.background = element_blank(), 34 | panel.border = element_blank(), 35 | strip.background = element_blank(), 36 | plot.background = element_blank(), 37 | axis.line = element_blank(), 38 | panel.grid = element_blank() 39 | ) 40 | if (!ticks) { 41 | ret <- ret + theme(axis.ticks = element_blank()) 42 | } 43 | ret 44 | } 45 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | #' Magic Number: Points to Millimeters 2 | #' @noRd 3 | PT_TO_MM <- 0.352778 # nolint: object_name_linter 4 | 5 | charopts <- function(x) { 6 | paste(sprintf("\\code{\"%s\"}", x), collapse = ", ") 7 | } 8 | 9 | # copied from ggplot2 10 | "%||%" <- function(a, b) { 11 | if (!is.null(a)) a else b 12 | } 13 | 14 | # copied from ggplot2 15 | ggname <- function(prefix, grob) { 16 | grob$name <- grid::grobName(grob, prefix) 17 | grob 18 | } 19 | 20 | rd_optlist <- function(x) { 21 | paste0("\\code{\"", as.character(x), "\"}", collapse = ", ") 22 | } 23 | 24 | check_pal_n <- function(n, max_n) { 25 | if (n > max_n) { 26 | warning( 27 | "This palette can handle a maximum of ", max_n, " values.", 28 | "You have supplied ", n, "." 29 | ) 30 | } else if (n < 0) { 31 | stop("`n` must be a non-negative integer.") 32 | } 33 | } 34 | 35 | #' Extract colors from ggthemes data 36 | #' 37 | #' @param path A character vector of the path in \code{ggthemes_data}. 38 | #' @param colors A character vector of color names. 39 | #' @noRd 40 | get_colors <- function(path, colors) { 41 | x <- dplyr::filter(ggthemes::ggthemes_data[[path]], .data$name %in% colors) 42 | x <- unname(x[["value"]]) 43 | } 44 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, echo = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-" 12 | ) 13 | ``` 14 | 15 | [![R-CMD-check](https://github.com/jrnold/ggthemes/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jrnold/ggthemes/actions/workflows/R-CMD-check.yaml) 16 | [![Code Coverage Status](https://codecov.io/gh/jrnold/ggthemes/branch/master/graph/badge.svg)](https://codecov.io/github/jrnold/ggthemes?branch=master) 17 | [![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/ggthemes)](https://github.com/metacran/cranlogs.app) 18 | [![CRAN status](https://www.r-pkg.org/badges/version/ggthemes)](https://CRAN.R-project.org/package=ggthemes) 19 | [![lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable) 20 | 21 | Some extra geoms, scales, and themes for 22 | [ggplot](https://ggplot2.tidyverse.org/). 23 | 24 | ## Install 25 | 26 | To install the stable version from CRAN, 27 | 28 | ```r 29 | install.packages('ggthemes', dependencies = TRUE) 30 | ``` 31 | 32 | Or, to install the development version from github, use the 33 | **devtools** package, 34 | 35 | ```r 36 | library("devtools") 37 | install_github(c("hadley/ggplot2", "jrnold/ggthemes")) 38 | ``` 39 | 40 | ## How to use 41 | 42 | For a quick tutorial, check out [Rafael Irizarry's book](https://rafalab.github.io/dsbook/ggplot2.html#add-on-packages). 43 | 44 | ## Examples 45 | 46 | ```{r} 47 | library("ggplot2") 48 | library("ggthemes") 49 | 50 | mtcars2 <- within(mtcars, { 51 | vs <- factor(vs, labels = c("V-shaped", "Straight")) 52 | am <- factor(am, labels = c("Automatic", "Manual")) 53 | cyl <- factor(cyl) 54 | gear <- factor(gear) 55 | }) 56 | 57 | p1 <- ggplot(mtcars2) + 58 | geom_point(aes(x = wt, y = mpg, colour = gear)) + 59 | labs( 60 | title = "Fuel economy declines as weight increases", 61 | subtitle = "(1973-74)", 62 | caption = "Data from the 1974 Motor Trend US magazine.", 63 | x = "Weight (1000 lbs)", 64 | y = "Fuel economy (mpg)", 65 | colour = "Gears" 66 | ) 67 | ``` 68 | 69 | ```{r,theme_calc} 70 | p1 + 71 | scale_color_calc() + 72 | theme_calc() 73 | ``` 74 | 75 | ```{r,theme_clean} 76 | p1 + theme_clean() 77 | ``` 78 | 79 | ```{r,theme_economist} 80 | p1 + theme_economist() + 81 | scale_colour_economist() 82 | ``` 83 | 84 | ```{r,theme_excel} 85 | p1 + theme_excel() + 86 | scale_colour_excel() 87 | ``` 88 | 89 | ```{r,theme_excel_new} 90 | p1 + theme_excel_new() + 91 | scale_colour_excel_new() 92 | ``` 93 | 94 | ```{r,theme_igray} 95 | p1 + theme_igray() 96 | ``` 97 | 98 | ```{r,theme_par} 99 | p1 + theme_par() 100 | ``` 101 | 102 | ```{r,theme_fivethirtyeight} 103 | p1 + theme_fivethirtyeight() 104 | ``` 105 | 106 | ```{r,theme_few} 107 | p1 + theme_few() + 108 | scale_colour_few() 109 | ``` 110 | ```{r,theme_solarized} 111 | p1 + theme_solarized() + 112 | scale_colour_solarized() 113 | ``` 114 | 115 | ```{r,theme_solarized_dark} 116 | p1 + theme_solarized(light=FALSE) + 117 | scale_colour_solarized() 118 | ``` 119 | 120 | ```{r,theme_solid} 121 | p1 + theme_solid() 122 | ``` 123 | 124 | ```{r,theme_stata} 125 | p1 + theme_tufte() 126 | ``` 127 | 128 | ```{r,theme_wsj} 129 | p1 + theme_wsj(base_size = 8) + scale_color_wsj() 130 | ``` 131 | 132 | ```{r,scale_colorblind} 133 | p1 + scale_color_colorblind() 134 | ``` 135 | 136 | ```{r,scale_color_tableau} 137 | p1 + scale_color_tableau() 138 | ``` 139 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: http://jrnold.github.io/ggthemes/ 2 | template: 3 | bootstrap: 5 4 | reference: 5 | - title: Themes 6 | contents: starts_with("theme_") 7 | - title: Color Scales 8 | desc: Provided ggplot2 scales for the `color` (`colour`) aesthetic. Scales control 9 | the details of how data values are translated to visual properties. 10 | contents: 11 | - starts_with("scale_color_") 12 | - starts_with("scale_fill_") 13 | - title: Shape Scales 14 | desc: Provided ggplot2 scales for the `shape` aesthetic. Scales control the details 15 | of how data values are translated to visual properties. 16 | contents: starts_with("scale_shape_") 17 | - title: Lintetype Scales 18 | desc: Provided ggplot2 scales for the `linetype` aesthetic. Scales control the details 19 | of how data values are translated to visual properties. 20 | contents: starts_with("scale_linetype_") 21 | - title: Color, Shape, and Linetype Palettes 22 | desc: Color, shape, and linetype palettes. 23 | contents: 24 | - ends_with("_pal") 25 | - palette_pander 26 | - title: Geoms and Stats 27 | desc: ggplot2 geom and stat layers. 28 | contents: 29 | - starts_with("geom_") 30 | - starts_with("stat_") 31 | - title: Other functions 32 | contents: 33 | - bank_slopes 34 | - extended_range_breaks 35 | - show_linetypes 36 | - show_shapes 37 | - smart_digits 38 | - title: Data 39 | contents: 40 | - ggthemes_data 41 | - canva_palettes 42 | 43 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | patch: 10 | default: 11 | target: auto 12 | threshold: 1% 13 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## R CMD check notes 2 | 3 | - "Author field differs from that derived from Authors@R" is due to use of 4 | an ORCID identifier. 5 | 6 | - "Note: found ... marked UTF-8 strings": The UTF strings are necessary to the package. 7 | They encode specific non-ASCII characters to use as symbols. 8 | 9 | - In `DESCRIPTION`, the words "Geoms", "Stata", "Tufte", "Tufte's", 10 | and "geoms" are not misspelled. 11 | 12 | - "Found the following (possibly) invalid URLs" check": The following URLs are valid. 13 | These URLs are listed along with errors that occur during checks. 14 | 15 | - https://policyviz.com/2017/01/12/150-color-palettes-for-excel/ (Times out) 16 | - https://spiekermann.com/en/itc-officina-display/ (libcurl error 38 "Connection timed out") 17 | - https://twitter.com/WSJGraphics (400) 18 | - https://www.canva.com/learn/ (403) 19 | - https://www.canva.com/learn/100-color-combinations/ (403) 20 | - https://www.canva.com/learn/website-color-schemes/ (403) 21 | - https://www.highcharts.com/ (503) 22 | - https://www.highcharts.com/demo (503) 23 | - https://www.jstor.org/stable/1390760 (403) 24 | - https://www.jstor.org/stable/2289649 (403) 25 | - https://www.perceptualedge.com/articles/visual_business_intelligence/rules_for_using_color.pdf (Could not resolve host: www.perceptualedge.com) 26 | -------------------------------------------------------------------------------- /data-raw/canva_palette.R: -------------------------------------------------------------------------------- 1 | #' #' Generate data/canva_palettes.rda 2 | #' #' 3 | #' #' The color list is from http://makeadifferencewithdata.com/2017/01/150-paletas-colores-tableau/, 4 | #' #' and referenced here: https://policyviz.com/2017/01/12/150-color-palettes-for-excel/. 5 | #' #' 6 | #' library("xml2") 7 | #' library("purrr") 8 | #' 9 | #' #' THIS URL IS NO longer valid 10 | #' color_palettes_url <- "http://makeadifferencewithdata.com/wp-content/uploads/2016/12/color-palettes.txt" 11 | #' 12 | #' color_palettes_txt <- readLines(color_palettes_url) 13 | #' 14 | #' tree <- 15 | #' read_xml(paste0("", 16 | #' paste0(color_palettes_txt, collapse = ""), 17 | #' "", 18 | #' collapse = "")) 19 | #' 20 | #' palette_names <- map_chr(xml_find_all(tree, "//color-palette"), 21 | #' ~ xml_attr(.x, "name")) 22 | #' 23 | #' palette_colors <- map(xml_find_all(tree, "//color-palette"), 24 | #' ~ xml_text(xml_find_all(.x, "./color"))) %>% 25 | #' # one of the palettes has a bad HTML code. See #78 26 | #' map(str_sub, 1, 7) 27 | #' 28 | #' canva_palettes <- set_names(palette_colors, palette_names) %>% 29 | #' # drop bad Trendy and metropolitan. See #78 30 | #' discard(~ .x[1] == "#") 31 | #' 32 | #' # Rename duplicate "Vintage charm" 33 | #' names(canva_palettes)[(names(canva_palettes) == "Vintage charm") & 34 | #' duplicated(names(canva_palettes))] <- "Vintage charm 2" 35 | #' 36 | #' # check that no duplicate names 37 | #' stopifnot(!any(duplicated(names(canva_palettes)))) 38 | #' 39 | #' dir.create("data", showWarnings = FALSE) 40 | #' save(canva_palettes, file = "data/canva_palettes.rda") 41 | -------------------------------------------------------------------------------- /data-raw/clean-colors.R: -------------------------------------------------------------------------------- 1 | library("jsonlite") 2 | 3 | themes <- read_json("data-raw/themes.json") 4 | -------------------------------------------------------------------------------- /data-raw/excel/mtcars.csv: -------------------------------------------------------------------------------- 1 | mpg,cyl,disp,hp,drat,wt,qsec,vs,am,gear,carb 2 | 21,6,160,110,3.9,2.62,16.46,0,1,4,4 3 | 21,6,160,110,3.9,2.875,17.02,0,1,4,4 4 | 22.8,4,108,93,3.85,2.32,18.61,1,1,4,1 5 | 21.4,6,258,110,3.08,3.215,19.44,1,0,3,1 6 | 18.7,8,360,175,3.15,3.44,17.02,0,0,3,2 7 | 18.1,6,225,105,2.76,3.46,20.22,1,0,3,1 8 | 14.3,8,360,245,3.21,3.57,15.84,0,0,3,4 9 | 24.4,4,146.7,62,3.69,3.19,20,1,0,4,2 10 | 22.8,4,140.8,95,3.92,3.15,22.9,1,0,4,2 11 | 19.2,6,167.6,123,3.92,3.44,18.3,1,0,4,4 12 | 17.8,6,167.6,123,3.92,3.44,18.9,1,0,4,4 13 | 16.4,8,275.8,180,3.07,4.07,17.4,0,0,3,3 14 | 17.3,8,275.8,180,3.07,3.73,17.6,0,0,3,3 15 | 15.2,8,275.8,180,3.07,3.78,18,0,0,3,3 16 | 10.4,8,472,205,2.93,5.25,17.98,0,0,3,4 17 | 10.4,8,460,215,3,5.424,17.82,0,0,3,4 18 | 14.7,8,440,230,3.23,5.345,17.42,0,0,3,4 19 | 32.4,4,78.7,66,4.08,2.2,19.47,1,1,4,1 20 | 30.4,4,75.7,52,4.93,1.615,18.52,1,1,4,2 21 | 33.9,4,71.1,65,4.22,1.835,19.9,1,1,4,1 22 | 21.5,4,120.1,97,3.7,2.465,20.01,1,0,3,1 23 | 15.5,8,318,150,2.76,3.52,16.87,0,0,3,2 24 | 15.2,8,304,150,3.15,3.435,17.3,0,0,3,2 25 | 13.3,8,350,245,3.73,3.84,15.41,0,0,3,4 26 | 19.2,8,400,175,3.08,3.845,17.05,0,0,3,2 27 | 27.3,4,79,66,4.08,1.935,18.9,1,1,4,1 28 | 26,4,120.3,91,4.43,2.14,16.7,0,1,5,2 29 | 30.4,4,95.1,113,3.77,1.513,16.9,1,1,5,2 30 | 15.8,8,351,264,4.22,3.17,14.5,0,1,5,4 31 | 19.7,6,145,175,3.62,2.77,15.5,0,1,5,6 32 | 15,8,301,335,3.54,3.57,14.6,0,1,5,8 33 | 21.4,4,121,109,4.11,2.78,18.6,1,1,4,2 34 | -------------------------------------------------------------------------------- /data-raw/excel/mtcars.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/data-raw/excel/mtcars.ods -------------------------------------------------------------------------------- /data-raw/excel/mtcars.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/data-raw/excel/mtcars.xlsx -------------------------------------------------------------------------------- /data-raw/excel_themes.R: -------------------------------------------------------------------------------- 1 | # nolint start 2 | # Extract Color Schemes from Excel 3 | # 4 | # Extract colors for all color themes on an installed version of Excel 5 | # and save them to a YAML file. 6 | # 7 | # See 8 | # 9 | # - https://support.office.com/en-us/article/change-a-theme-and-make-it-the-default-in-word-or-excel-c846f997-968e-4daa-b2d4-42bd2afef904?ui=en-US&rs=en-US&ad=US 10 | # - https://msdn.microsoft.com/en-us/library/cc964302(v=office.12).aspx 11 | # - https://support.office.com/en-us/article/open-xml-formats-and-file-name-extensions-5200d93c-3449-4380-8e11-31ef14555b18 12 | # 13 | # nolint end 14 | 15 | # This no longer works as of 2024-02-09. 16 | 17 | # suppressPackageStartupMessages({ 18 | # library("xml2") 19 | # library("purrr") 20 | # library("here") 21 | # library("yaml") 22 | # library("stringr") 23 | # }) 24 | 25 | # theme_dir <- "/Applications/Microsoft Excel.app/Contents/Resources/Office Themes" 26 | # color_dir <- file.path(theme_dir, "Theme Colors") 27 | 28 | # thmx_files <- dir(theme_dir, pattern = "\\.thmx$", full.names = TRUE) 29 | # color_theme_files <- dir(color_dir, pattern = "\\.xml$", full.names = TRUE) 30 | 31 | # process_color <- function(x) { 32 | # name <- xml_name(x) 33 | # clr <- xml_child(x) 34 | # if (xml_name(clr) == "srgbClr") { 35 | # val <- xml_attr(clr, "val") 36 | # } else if (xml_name(clr) == "sysClr") { 37 | # val <- xml_attr(clr, "lastClr") 38 | # } 39 | # set_names(list(val), name) 40 | # } 41 | 42 | # process_clr_scheme <- function(x) { 43 | # scheme_name <- xml_attr(x, "name") 44 | # colors <- flatten_chr(map(xml_children(x), process_color)) 45 | # list( 46 | # colors = list( 47 | # accents = str_c( 48 | # "#", 49 | # unname(colors[str_subset(names(colors), "^accent")]) 50 | # ), 51 | # dk = str_c("#", unname(colors[c("dk1", "dk2")])), 52 | # lt = str_c("#", unname(colors[c("lt1", "lt2")])), 53 | # hlink = list( 54 | # "default" = str_c("#", colors[["hlink"]]), 55 | # "followed" = str_c("#", colors[["folHlink"]]) 56 | # ) 57 | # ), 58 | # name = scheme_name 59 | # ) 60 | # } 61 | 62 | # read_office_color_theme <- function(path) { 63 | # tree <- read_xml(path) 64 | # process_clr_scheme(xml_find_first(tree, "//a:clrScheme")) 65 | # } 66 | 67 | # read_thmx_colors <- function(path) { 68 | # theme1 <- unz(path, "theme/theme/theme1.xml") 69 | # read_office_color_theme(theme1) 70 | # } 71 | 72 | # themes <- c( 73 | # map(thmx_files, read_thmx_colors), 74 | # map(color_theme_files, read_office_color_theme) 75 | # ) 76 | 77 | # names(themes) <- map_chr(themes, "name") 78 | # for (i in names(themes)) { 79 | # themes[[i]] <- themes[[i]][["colors"]] 80 | # } 81 | 82 | # cat(as.yaml(themes), 83 | # file = here("data-raw", "theme-data", "excel-themes.yml") 84 | # ) 85 | -------------------------------------------------------------------------------- /data-raw/libreoffice_palettes.R: -------------------------------------------------------------------------------- 1 | suppressPackageStartupMessages({ 2 | library("tibble") 3 | library("xml2") 4 | }) 5 | 6 | # https://www.openoffice.org/xml/xml_specification.pdf 7 | # 8 | # LibreOffice colors can be found at 9 | # https://design.blog.documentfoundation.org/2016/11/11/additions-to-libreoffice/ 10 | # Also see: https://community.kde.org/KDE_Visual_Design_Group/HIG/Color 11 | 12 | #' @importFrom xml2 xml_attr 13 | soc_process_color <- function(x) { 14 | list( 15 | name = xml_attr(x, "draw:name"), 16 | color = xml_attr(x, "draw:color") 17 | ) 18 | } 19 | 20 | 21 | soc_process_color <- function(x) { 22 | tibble( 23 | name = xml_attr(x, "name"), 24 | value = xml_attr(x, "color") 25 | ) 26 | } 27 | 28 | read_soc <- function(path) { 29 | map_dfr(xml_find_all(read_xml(path), "draw:color"), soc_process_color) 30 | } 31 | 32 | palettes <- 33 | c("chart-palettes") 34 | # "freecolour-hlc", 35 | # "html", 36 | # "libreoffice", 37 | # "standard", 38 | # "tonal") 39 | 40 | palette_url <- function(name) { 41 | str_c( 42 | "https://raw.githubusercontent.com/LibreOffice/core/", 43 | "master/extras/source/palettes/", name, ".soc" 44 | ) 45 | } 46 | 47 | chart_palette <- read_soc(palette_url("chart-palettes")) 48 | 49 | cat(yaml::as.yaml(chart_palette, column.major = FALSE)) 50 | -------------------------------------------------------------------------------- /data-raw/stata/examples.do: -------------------------------------------------------------------------------- 1 | sysuse auto 2 | local schemelist s2color s2mono s2manual s2gmanual s1rcolor s1mono s1manual economist sj 3 | 4 | foreach scheme of local schemelist { 5 | scatter mpg headroom turn weight, /// 6 | title("Plot title") legend(title("Legend title")) scheme(`scheme') 7 | graph export "graph_twoway_scatter_`scheme'.png" 8 | 9 | scatter mpg headroom turn weight, /// 10 | by(foreign, title("Plot title")) /// 11 | legend(title("Legend title")) scheme(`scheme') 12 | graph export "graph_twoway_scatter_by_`scheme'.png" 13 | } 14 | -------------------------------------------------------------------------------- /data-raw/theme-data/colorblind.yml: -------------------------------------------------------------------------------- 1 | - {name: 'Black', value: '#000000'} 2 | - {name: 'Orange', value: '#E69F00'} 3 | - {name: 'Sky Blue', value: '#56B4E9'} 4 | - {name: 'Bluish Green', value: '#009E73'} 5 | - {name: 'Yellow', value: '#F0E442'} 6 | - {name: 'Blue', value: '#0072B2'} 7 | - {name: 'Vermillion', value: '#D55E00'} 8 | - {name: 'Reddish Purple', value: '#CC79A7'} 9 | -------------------------------------------------------------------------------- /data-raw/theme-data/economist.yml: -------------------------------------------------------------------------------- 1 | bg: 2 | - {name: "blue-gray", value: '#d5e4eb'} 3 | - {name: "dark blue-gray", value: '#c3d6df'} 4 | - {name: "red", value: '#ed111a'} 5 | - {name: "light gray", value: '#ebebeb'} 6 | - {name: "dark gray", value: '#c9c9c9'} 7 | fg: 8 | - {name: "blue-gray", value: '#6794a7'} 9 | - {name: "dark blue", value: '#014d64'} 10 | - {name: "light green", value: '#76c0c1'} 11 | - {name: "blue", value: '#01a2d9'} 12 | - {name: "light blue", value: '#7ad2f6'} 13 | - {name: "dark green", value: '#00887d'} 14 | - {name: "gray", value: '#adadad'} 15 | - {name: "light blue", value: '#7bd3f6'} 16 | - {name: "dark red", value: '#7c260b'} 17 | - {name: "pink", value: '#ee8f71'} 18 | - {name: "light green", value: '#76c0c1'} 19 | - {name: "brown", value: '#a18376'} 20 | -------------------------------------------------------------------------------- /data-raw/theme-data/excel.yml: -------------------------------------------------------------------------------- 1 | classic: 2 | line: ['#FF00FF', '#FFFF00', '#00FFFF', '#800080', '#800000', '#008080', '#0000FF'] 3 | fill: ['#993366', '#FFFFCC', '#CCFFFF', '#660066', '#FF8080', '#0066CC', '#CCCCFF'] 4 | shapes: 5 | - {name: Circle, label: 'BLACK CIRCLE', unicode: U+25CF, character: ●} 6 | - {label: Square, name: 'BLACK MEDIUM SQUARE', unicode: U+25FC, character: ◼} 7 | - {label: Diamond, name: 'BLACK DIAMOND', unicode: U+25C6, character: ◆} 8 | - {name: Triangle, label: 'BLACK UP-POINTING TRIANGLE', unicode: U+25B2, character: ▲} 9 | - {name: 'MULTIPLICATION X', unicode: U+2715, character: ✕} 10 | - {name: 'LIGHT SIX SPOKED ASTERISK', unicode: U+1F7B5, character: 🞵} 11 | - {name: HYPHEN-MINUS, unicode: U+002D, character: '-'} 12 | - {name: 'EM DASH', unicode: U+2013, character: —} 13 | - {name: 'PLUS SIGN', character: +, unicode: U+002B} 14 | -------------------------------------------------------------------------------- /data-raw/theme-data/few.yml: -------------------------------------------------------------------------------- 1 | colors: 2 | Light: 3 | - {name: Gray, value: '#8C8C8C'} 4 | - {name: Blue, value: '#88BDE6'} 5 | - {name: Orange, value: '#FBB258'} 6 | - {name: Green, value: '#90CD97'} 7 | - {name: Pink, value: '#F6AAC9'} 8 | - {name: Brown, value: '#BFA554'} 9 | - {name: Purple, value: '#BC99C7'} 10 | - {name: Yellow, value: '#EDDD46'} 11 | - {name: Red, value: '#F07E6E'} 12 | Medium: 13 | - {name: Gray, value: '#4D4D4D'} 14 | - {name: Blue, value: '#5DA5DA'} 15 | - {name: Orange, value: '#FAA43A'} 16 | - {name: Green, value: '#60BD68'} 17 | - {name: Pink, value: '#F17CB0'} 18 | - {name: Brown, value: '#B2912F'} 19 | - {name: Purple, value: '#B276B2'} 20 | - {name: Yellow, value: '#DECF3F'} 21 | - {name: Red, value: '#F15854'} 22 | 'Dark': 23 | - {name: Gray, value: '#000000'} 24 | - {name: Blue, value: '#265DAB'} 25 | - {name: Orange, value: '#DF5C24'} 26 | - {name: Green, value: '#059748'} 27 | - {name: Pink, value: '#E5126F'} 28 | - {name: Brown, value: '#9D722A'} 29 | - {name: Purple, value: '#7B3A96'} 30 | - {name: Yellow, value: '#C7B42E'} 31 | - {name: Red, value: '#CB2027'} 32 | shapes: 33 | - {name: 'WHITE CIRCLE', pch: 1, character: "○", unicode: U+25CB} 34 | - {name: 'WHITE SQUARE', pch: 0, unicode: "U+25A1", character: "□"} 35 | - {name: 'WHITE UP-POINTING TRIANGLE', unicode: U+25B3, character: "△", pch: 2} 36 | - {name: 'PLUS SIGN', pch: 3, character: "+", unicode: U+002B} 37 | - {name: 'MULTIPLICATION X', unicode: U+2715, character: ✕, pch: 4} 38 | -------------------------------------------------------------------------------- /data-raw/theme-data/fivethirtyeight.yml: -------------------------------------------------------------------------------- 1 | - {name: "Dark Gray", value: '#3C3C3C'} 2 | - {name: "Medium Gray", value: '#D2D2D2'} 3 | - {name: "Light Gray", value: '#F0F0F0'} 4 | - {name: "Red", value: '#FF2700'} 5 | - {name: "Blue", value: '#008FD5'} 6 | - {name: "Green", value: '#77AB43'} 7 | -------------------------------------------------------------------------------- /data-raw/theme-data/gdocs.yml: -------------------------------------------------------------------------------- 1 | colors: 2 | - name: blue 3 | value: "#4285f4" 4 | - name: red 5 | value: "#ea4335" 6 | - name: yellow 7 | value: "#fbbc04" 8 | - name: green 9 | value: "#34a853" 10 | - name: orange 11 | value: "#ff6d01" 12 | - name: teal 13 | value: "#46bdc6" 14 | 15 | - name: blue 2 16 | value: "#7baaf7" 17 | - name: red 2 18 | value: "#f07b72" 19 | - name: yellow 2 20 | value: "#fcd04f" 21 | - name: green 2 22 | value: "#71c287" 23 | - name: orange 2 24 | value: "#ff994d" 25 | - name: teal 2 26 | value: "#ff994d" 27 | 28 | - name: blue 3 29 | value: "#b3cefb" 30 | - name: red 3 31 | value: "#f7b4ae" 32 | - name: yellow 3 33 | value: "#fde49b" 34 | - name: green 3 35 | value: "#aedcba" 36 | - name: orange 3 37 | value: "#ffc599" 38 | - name: teal 3 39 | value: "#c9e4e7" 40 | 41 | 42 | - name: blue 4 43 | value: "#ecf3fe" 44 | - name: red 4 45 | value: "#fdeceb" 46 | - name: yellow 4 47 | value: "#fff8e6" 48 | - name: green 4 49 | value: "#ebf6ee" 50 | - name: orange 4 51 | value: "#fff0e6" 52 | - name: teal 4 53 | value: "#edf8f9" 54 | 55 | shapes: 56 | - {name: Circle, label: 'BLACK CIRCLE', unicode: U+25CF, character: ●} 57 | - {name: Triangle, label: 'BLACK UP-POINTING TRIANGLE', unicode: U+25B2, character: ▲} 58 | - {label: Square, name: 'BLACK MEDIUM SQUARE', unicode: U+25FC, character: ◼} 59 | - {label: Diamond, name: 'BLACK DIAMOND', unicode: U+25C6, character: ◆} 60 | - {label: Star, name: 'MULTIPLICATION X', unicode: U+2605, character: ★} 61 | - {label: 'X mark', name: 'MULTIPLICATION X', unicode: U+2715, character: ✕} 62 | - {label: Pentagon, name: 'BLACK PENTAGON', unicode: U+2B1F, character: ⬟} 63 | - {label: Hexagon, name: 'BLACK HEXAGON', unicode: U+2B22, character: ⬢} 64 | -------------------------------------------------------------------------------- /data-raw/theme-data/hc.yml: -------------------------------------------------------------------------------- 1 | "default": 2 | - "#7cb5ec" 3 | - "#434348" 4 | - "#90ed7d" 5 | - "#f7a35c" 6 | - "#8085e9" 7 | - "#f15c80" 8 | - "#e4d354" 9 | - "#8085e8" 10 | - "#8d4653" 11 | - "#91e8e1" 12 | "darkunica": 13 | - "#2b908f" 14 | - "#90ee7e" 15 | - "#f45b5b" 16 | - "#7798BF" 17 | - "#aaeeee" 18 | - "#ff0066" 19 | - "#eeaaee" 20 | - "#55BF3B" 21 | - "#DF5353" 22 | - "#7798BF" 23 | - "#aaeeee" 24 | -------------------------------------------------------------------------------- /data-raw/theme-data/highcharts.yml: -------------------------------------------------------------------------------- 1 | palettes: {default: ['#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#8085e8', '#8d4653', '#91e8e1'], darkunica: ['#2b908f', '#90ee7e', '#f45b5b', '#7798BF', '#aaeeee', '#ff0066', '#eeaaee', '#55BF3B', '#DF5353', '#7798BF', '#aaeeee']} 2 | bg: [{name: default, value: '#FFFFFF'}, {name: darkunica, value: '#2a2a2b'}] 3 | -------------------------------------------------------------------------------- /data-raw/theme-data/libreoffice.yml: -------------------------------------------------------------------------------- 1 | shapes: 2 | - {name: 'BLACK SQUARE', unicode: "U+25A0", character: "■"} 3 | - {name: 'BLACK DIAMOND', unicode: "U+25C6", character: "◆"} 4 | - {name: 'BLACK DOWN-POINTING CHARACTER', unicode: "U+25BC", character: "▼"} 5 | - {name: 'BLACK UP-POINTING TRIANGLE', unicode: "U+25B2", character: "▲"} 6 | - {name: 'BLACK RIGHT-POINTING TRIANGLE', unicode: "U+25B6", character: "▶"} 7 | - {name: 'BLACK LEFT-POINTING TRIANGLE', unicode: "U+25C0", character: "◀"} 8 | - {name: 'BLACK BOWTIE', unicode: "U+29D3", character: "⧓"} 9 | - {name: 'BLACK HOURGLASS', unicode: "U+29D7", character: "⧗"} 10 | - {name: 'BLACK CIRCLE', unicode: "U+25CF", character: "●"} 11 | - {name: 'BLACK FOUR POINTED STAR', unicode: "U+2726", character: "✦"} 12 | - {name: 'MULTIPLICATION X', unicode: "U+2715", character: "✕"} 13 | - {name: 'PLUS SIGN', unicode: "U+002B", character: "+"} 14 | - {name: 'ASTERISK OPERATOR', unicode: "U+2217", character: "∗"} 15 | # - {name: 'HEAVY MINUS SIGN', unicode: "U+2796", character: "➖} 16 | # - {name: 'MEDIUM VERTICAL BAR', unicode: "U+2759", character: ❙} 17 | colors: 18 | - name: Chart 1 19 | value: '#004586' 20 | - name: Chart 2 21 | value: '#ff420e' 22 | - name: Chart 3 23 | value: '#ffd320' 24 | - name: Chart 4 25 | value: '#579d1c' 26 | - name: Chart 5 27 | value: '#7e0021' 28 | - name: Chart 6 29 | value: '#83caff' 30 | - name: Chart 7 31 | value: '#314004' 32 | - name: Chart 8 33 | value: '#aecf00' 34 | - name: Chart 9 35 | value: '#4b1f6f' 36 | - name: Chart 10 37 | value: '#ff950e' 38 | - name: Chart 11 39 | value: '#c5000b' 40 | - name: Chart 12 41 | value: '#0084d1' 42 | -------------------------------------------------------------------------------- /data-raw/theme-data/manyeyes.yml: -------------------------------------------------------------------------------- 1 | - '#9c9ede' 2 | - '#7375b5' 3 | - '#4a5584' 4 | - '#cedb9c' 5 | - '#b5cf6b' 6 | - '#8ca252' 7 | - '#637939' 8 | - '#e7cb94' 9 | - '#e7ba52' 10 | - '#bd9e39' 11 | - '#8c6d31' 12 | - '#e7969c' 13 | - '#d6616b' 14 | - '#ad494a' 15 | - '#843c39' 16 | - '#de9ed6' 17 | - '#ce6dbd' 18 | - '#a55194' 19 | - '#7b4173' 20 | -------------------------------------------------------------------------------- /data-raw/theme-data/numbers-charts.yml: -------------------------------------------------------------------------------- 1 | chart1: 2 | - name: blue 3 | value: "#00a3d7" 4 | - name: green 5 | value: "#6ebb46" 6 | - name: yellow 7 | value: "#f6c100" 8 | - name: orange 9 | value: "#ff6a00" 10 | - name: red 11 | value: "#e32400" 12 | - name: purple 13 | value: "#423ba8" 14 | chart2: 15 | - name: green 16 | value: "#409f0f" 17 | - name: dark gray 18 | value: "#444444" 19 | - name: light green 20 | value: "#85cc82" 21 | - name: dark gray 22 | value: "#5e5e64" 23 | - name: green 24 | value: "#60b336" 25 | - name: gray 26 | value: "#89847f" 27 | chart3: 28 | - name: orange 29 | value: "#ff9e41" 30 | - name: gray 31 | value: "#89847f" 32 | - name: orange 33 | value: "#ff8127" 34 | - name: gray 35 | value: "#b4aea7" 36 | - name: light orange 37 | value: "#ffba66" 38 | - name: dark gray 39 | value: "#5f5f5f" 40 | chart4: 41 | - name: blue 42 | value: "#00a3d7" 43 | alpha: 0.85 44 | - name: light blue 45 | value: "#68d6ff" 46 | alpha: 0.85 47 | - name: teal 48 | value: "#0ba5bf" 49 | alpha: 0.85 50 | - name: light blue 51 | value: "#41bceb" 52 | alpha: 0.85 53 | - name: blue 54 | value: "#004d84" 55 | alpha: 0.85 56 | - name: blue 57 | value: "#0077c1" 58 | alpha: 0.85 59 | chart5: 60 | - name: gray 61 | value: "#89847f" 62 | - name: gray 63 | value: "#aea9a2" 64 | - name: dark gray 65 | value: "#606060" 66 | - name: dark gray 67 | value: "#232323" 68 | - name: light gray 69 | value: "#d8d2c8" 70 | - name: dark gray 71 | value: "#444444" 72 | chart6: 73 | - name: purple 74 | value: "#5862c2" 75 | alpha: 0.85 76 | - name: teal 77 | value: "#2ec6ff" 78 | alpha: 0.85 79 | - name: green 80 | value: "#79c850" 81 | alpha: 0.85 82 | - name: orange 83 | value: "#ffaa41" 84 | alpha: 0.85 85 | - name: red 86 | value: "#fc5937" 87 | alpha: 0.85 88 | - name: gray 89 | value: "#89847f" 90 | alpha: 0.85 91 | -------------------------------------------------------------------------------- /data-raw/theme-data/pault.yml: -------------------------------------------------------------------------------- 1 | qualitative: 2 | - ['#4477AA'] 3 | - ['#4477AA', '#CC6677'] 4 | - ['#4477AA', '#DDCC77', '#CC6677'] 5 | - ['#4477AA', '#117733', '#DDCC77', '#CC6677'] 6 | - ['#4477AA', '#88CCEE', '#117733', '#DDCC77', '#CC6677'] 7 | - ['#4477AA', '#88CCEE', '#117733', '#DDCC77', '#CC6677', '#AA4499'] 8 | - ['#332288', '#88CCEE', '#44AA99', '#117733', '#DDCC77', '#CC6677', '#AA4499'] 9 | - ['#332288', '#88CCEE', '#44AA99', '#117733', '#999933', '#DDCC77', '#CC6677', '#AA4499'] 10 | - ['#332288', '#88CCEE', '#44AA99', '#117733', '#999933', '#DDCC77', '#CC6677', '#882255', '#AA4499'] 11 | - ['#332288', '#88CCEE', '#44AA99', '#117733', '#999933', '#DDCC77', '#661100', '#CC6677', '#882255', '#AA4499'] 12 | - ['#332288', '#6699CC', '#88CCEE', '#44AA99', '#117733', '#999933', '#DDCC77', '#661100', '#CC6677', '#882255', '#AA4499'] 13 | - ['#332288', '#6699CC', '#88CCEE', '#44AA99', '#117733', '#999933', '#DDCC77', '#661100', '#CC6677', '#AA4466', '#882255', '#AA4499'] 14 | -------------------------------------------------------------------------------- /data-raw/theme-data/shapes.yml: -------------------------------------------------------------------------------- 1 | cleveland: 2 | overlap: 3 | - {name: 'WHITE CIRCLE', pch: 1, character: "○", unicode: U+25CB} 4 | - {name: 'PLUS SIGN', pch: 3, character: "+", unicode: U+002B} 5 | - {name: 'LESS-THAN SIGN', pch: 60, character: '<', unicode: U+003C} 6 | - {name: 'LATIN CAPITAL LETTER S', pch: 87, unicode: U+0053, character: "S"} 7 | default: 8 | - {name: 'WHITE CIRCLE', unicode: U+25CB, character: ○} 9 | - {name: 'BLACK CIRCLE', unicode: U+25CF, character: ●} 10 | - {name: 'CIRCLED PLUS', unicode: U+2295, character: ⊕} 11 | - {name: 'CIRCLED DOT OPERATOR', unicode: U+2299, character: ⊙} 12 | - {name: 'CIRCLED RING OPERATOR', unicode: U+229A, character: ⊚} 13 | circlefill: 14 | - {name: 'WHITE CIRCLE', unicode: U+25CB, character: ○} 15 | - {name: 'BLACK CIRCLE', unicode: U+25CF, character: ●} 16 | - {name: 'CIRCLE WITH UPPER HALF BLACK', unicode: U+25D3, character: ◓} 17 | - {name: 'CIRCLE WITH ALL BUT UPPER LEFT QUADRANT BLACK', unicode: U+25D5, character: ◕} 18 | - {name: 'CIRCLE WITH UPPER RIGHT QUADRANT BLACK', unicode: U+25D4, character: ◔} 19 | tremmel: 20 | '1': 21 | - {pch: 16, name: 'BLACK CIRCLE', unicode: U+25CF, character: ●} 22 | '2': 23 | - {name: 'BLACK CIRCLE', unicode: U+25CF, character: ●, pch: 16} 24 | - {name: 'WHITE CIRCLE', unicode: U+25CB, character: ○, pch: 1} 25 | '3': 26 | - {name: 'BLACK CIRCLE', unicode: U+25CF, character: ●, pch: 16} 27 | - {name: 'WHITE CIRCLE', unicode: U+25CB, character: ○, pch: 1} 28 | - {name: 'WHITE UP-POINTING TRIANGLE', unicode: U+25B3, character: △, pch: 2} 29 | '2-overlap': 30 | - {name: 'WHITE SQUARE', unicode: U+25A1, character: □, pch: 0} 31 | - {name: 'WHITE CIRCLE', unicode: U+25CB, character: ○, pch: 3} 32 | '3-alternate': 33 | - {name: 'BLACK CIRCLE', unicode: U+25CF, character: ●, pch: 16} 34 | - {name: 'WHITE SQUARE', unicode: U+25A1, character: □, pch: 1} 35 | - {name: 'WHITE UP-POINTING TRIANGLE', unicode: U+25B3, character: △, pch: 2} 36 | #harvey: 37 | # - {name: 'LARGE CIRCLE', character: ○, unicode: U+25CB} 38 | # - {name: 'CIRCLE WITH UPPER RIGHT QUADRANT BLACK', character: ◔, unicode: U+25D4} 39 | # - {name: 'CIRCLE WITH RIGHT HALF BLACK', character: ◑, unicode: U+25D1}# 40 | # - {character: ◕, name: 'CIRCLE WITH ALL BUT UPPER LEFT QUADRANT BLACK', unicode: U+25D5} 41 | # - {name: 'BLACK CIRCLE', character: ●, unicode: U+25CF} 42 | -------------------------------------------------------------------------------- /data-raw/theme-data/solarized.yml: -------------------------------------------------------------------------------- 1 | Base: 2 | - {name: base03, value: '#002b36'} 3 | - {name: base02, value: '#073642'} 4 | - {name: base01, value: '#586e75'} 5 | - {name: base00, value: '#657b83'} 6 | - {name: base0, value: '#839496'} 7 | - {name: base1, value: '#93a1a1'} 8 | - {name: base2, value: '#eee8d5'} 9 | - {name: base3, value: '#fdf6e3'} 10 | Accents: 11 | - {name: yellow, value: '#b58900'} 12 | - {name: orange, value: '#cb4b16'} 13 | - {name: red, value: '#dc322f'} 14 | - {name: magenta, value: '#d33682'} 15 | - {name: violet, value: '#6c71c4'} 16 | - {name: blue, value: '#268bd2'} 17 | - {name: cyan, value: '#2aa198'} 18 | - {name: green, value: '#859900'} 19 | -------------------------------------------------------------------------------- /data-raw/theme-data/wsj.yml: -------------------------------------------------------------------------------- 1 | bg: [{name: gray, value: '#efefef'}, {name: green, value: '#e9f3ea'}, {name: blue, value: '#d4dee7'}, {name: brown, value: '#f8f2e4'}] 2 | palettes: {rgby: [{name: yellow, value: '#d3ba68'}, {name: red, value: '#d5695d'}, {name: blue, value: '#5d8ca8'}, {name: green, value: '#65a479'}], red_green: [{name: green, value: '#088158'}, {name: red, value: '#ba2f2a'}], black_green: [{name: black, value: '#000000'}, {name: gray, value: '#595959'}, {name: ltgreen, value: '#59a77f'}, {name: green, value: '#008856'}], dem_rep: [{name: blue, value: '#006a8e'}, {name: red, value: '#b1283a'}, {name: gray, value: '#a8a6a7'}], colors6: [{name: red, value: '#c72e29'}, {name: blue, value: '#016392'}, {name: gold, value: '#be9c2e'}, {name: green, value: '#098154'}, {name: orange, value: '#fb832d'}, {name: black, value: '#000000'}]} 3 | -------------------------------------------------------------------------------- /data/canva_palettes.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/data/canva_palettes.rda -------------------------------------------------------------------------------- /data/ggthemes_data.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/data/ggthemes_data.rda -------------------------------------------------------------------------------- /ggthemes.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 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace,vignette 22 | -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | ACM 2 | Agrawala 3 | al 4 | Analytics 5 | AppVeyor 6 | Argwala 7 | Banff 8 | Beamer 9 | behaviour 10 | Bembo 11 | blosxom 12 | bowerth 13 | bugfix 14 | Bugfix 15 | calc 16 | Calc 17 | canva 18 | Canva 19 | cartesian 20 | cgi 21 | charactger 22 | CMD 23 | colores 24 | colour 25 | Colour 26 | continous 27 | coord 28 | cran 29 | daroczig 30 | de 31 | devtools 32 | et 33 | extrafont 34 | fivethirtyeight 35 | FiveThirtyEight 36 | gdocs 37 | geoms 38 | Geoms 39 | glyphs 40 | ggplot 41 | github 42 | grey 43 | Hanrahan 44 | hc 45 | Heer 46 | hexa 47 | Highcharts 48 | http 49 | https 50 | impactful 51 | Impactful 52 | InfoVis 53 | Irizarry's 54 | ITC 55 | jbkunst 56 | JS 57 | Kliever 58 | Lewandowsky 59 | LibreOffic 60 | lifecycle 61 | linepattern 62 | linetype 63 | Linetype 64 | linetypes 65 | Lothar 66 | lty 67 | Maneesh 68 | McGill 69 | nd 70 | Officina 71 | orcid 72 | paletas 73 | paul 74 | Pinterest 75 | pkgdown 76 | plotmath 77 | PolicyViz 78 | ptoche 79 | ptol 80 | pts 81 | quartile 82 | rcolor 83 | rlang 84 | rstudio 85 | Saenz 86 | SandyMuspratt 87 | Schoonover's 88 | Schwabish 89 | sj 90 | solarized 91 | Solarized 92 | Spiekerblog 93 | SRON 94 | stata 95 | Stata 96 | Stribley 97 | Tabaleau 98 | Tableu 99 | Tejeda 100 | thatn 101 | tol 102 | Tol 103 | Tol's 104 | tradeblotter 105 | Tremmel 106 | tufte 107 | Tufte 108 | Tufte's 109 | unica 110 | unicode 111 | vdiffr 112 | Verdana 113 | weitzner 114 | wordpress 115 | WS 116 | wsj 117 | WSJ 118 | Zdeb 119 | -------------------------------------------------------------------------------- /inst/examples/ex-bank_slopes.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | # Use the classic sunspot data from Cleveland's original paper 4 | x <- seq_along(sunspot.year) 5 | y <- as.numeric(sunspot.year) 6 | # Without banking 7 | m <- ggplot(data.frame(x = x, y = y), aes(x = x, y = y)) + 8 | geom_line() 9 | m 10 | 11 | ## Using the default method, Median Absolute Slope 12 | ratio <- bank_slopes(x, y) 13 | m + coord_fixed(ratio = ratio) 14 | ## Using culling 15 | ## Average Absolute Slope 16 | bank_slopes(x, y, method = "as") 17 | -------------------------------------------------------------------------------- /inst/examples/ex-calc_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(calc_pal()(12)) 4 | -------------------------------------------------------------------------------- /inst/examples/ex-calc_shape_pal.R: -------------------------------------------------------------------------------- 1 | \dontrun{ 2 | library("ggplot2") 3 | show_shapes(calc_shape_pal()(13)) 4 | } 5 | -------------------------------------------------------------------------------- /inst/examples/ex-canva_pal.R: -------------------------------------------------------------------------------- 1 | require("ggplot2") 2 | require("tibble") 3 | if (require("purrr") && require("scales") && require("dplyr")) { 4 | canva_df <- map2_df( 5 | canva_palettes, 6 | names(canva_palettes), 7 | ~ tibble( 8 | colors = .x, 9 | .id = seq_along(colors), 10 | palette = .y 11 | ) 12 | ) 13 | ggplot(canva_df, aes( 14 | y = palette, 15 | x = .id, 16 | fill = colors 17 | )) + 18 | geom_raster() + 19 | scale_fill_identity(guide = FALSE) + 20 | theme_minimal() + 21 | theme( 22 | panel.grid = element_blank(), 23 | axis.text.x = element_blank() 24 | ) + 25 | labs(x = "", y = "") 26 | 27 | show_col(canva_pal("Fresh and bright")(4)) 28 | show_col(canva_pal("Cool blues")(4)) 29 | show_col(canva_pal("Modern and crisp")(4)) 30 | } 31 | -------------------------------------------------------------------------------- /inst/examples/ex-cleveland_shape_pal.R: -------------------------------------------------------------------------------- 1 | ### (discrete). 2 | 3 | \dontrun{ 4 | library("ggplot2") 5 | p <- ggplot(mtcars) + 6 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 7 | facet_wrap(~am) + 8 | theme_bw() 9 | # overlapping symbol palette 10 | p + scale_shape_cleveland() 11 | # non-overlapping symbol palette 12 | p + scale_shape_cleveland(overlap = FALSE) 13 | } 14 | -------------------------------------------------------------------------------- /inst/examples/ex-colorblind.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | library("scales") 3 | 4 | show_col(colorblind_pal()(8)) 5 | p <- ggplot(mtcars) + 6 | geom_point(aes( 7 | x = wt, y = mpg, 8 | colour = factor(gear) 9 | )) + 10 | facet_wrap(~am) 11 | p + theme_igray() + scale_colour_colorblind() 12 | -------------------------------------------------------------------------------- /inst/examples/ex-economist_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(economist_pal()(6)) 4 | ## fill palette 5 | show_col(economist_pal(fill = TRUE)(6)) 6 | -------------------------------------------------------------------------------- /inst/examples/ex-excel_new_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | for (i in names(ggthemes::ggthemes_data$excel$palettes)) { 4 | show_col(excel_new_pal(theme = i))(6) 5 | } 6 | -------------------------------------------------------------------------------- /inst/examples/ex-excel_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(excel_pal()(7)) 4 | show_col(excel_pal(line = FALSE)(7)) 5 | -------------------------------------------------------------------------------- /inst/examples/ex-few_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(few_pal()(7)) 4 | show_col(few_pal("Dark")(7)) 5 | show_col(few_pal("Light")(7)) 6 | -------------------------------------------------------------------------------- /inst/examples/ex-few_shape_pal.R: -------------------------------------------------------------------------------- 1 | \dontrun{ 2 | # need to set a font containing unicode values 3 | show_shapes(few_shape_pal()(5)) 4 | } 5 | -------------------------------------------------------------------------------- /inst/examples/ex-fivethirtyeight_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(fivethirtyeight_pal()(3)) 4 | -------------------------------------------------------------------------------- /inst/examples/ex-gdocs_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(gdocs_pal()(24)) 4 | -------------------------------------------------------------------------------- /inst/examples/ex-geom_rangeframe.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | ggplot(mtcars, aes(wt, mpg)) + 4 | geom_point() + 5 | geom_rangeframe() + 6 | coord_cartesian(clip = "off") + 7 | theme_tufte() 8 | 9 | # In the example above, 10 | # `coord_cartesian(clip="off")`` ensures that the full width of the line is drawn. 11 | # if you know a better way to fix this, 12 | # please open an issue or PR on github https://github.com/jrnold/ggthemes/issue 13 | -------------------------------------------------------------------------------- /inst/examples/ex-geom_tufteboxplot.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars, aes(factor(cyl), mpg)) 4 | # with a point for the median and lines for whiskers 5 | p + geom_tufteboxplot() 6 | # with a line for the interquartile range and points for whiskers 7 | p + geom_tufteboxplot(median.type = "line", whisker.type = "point", hoffset = 0) 8 | # with a wide line for the interquartile range and lines for whiskers 9 | p + geom_tufteboxplot(median.type = "line", hoffset = 0, width = 3) 10 | # with an offset line for the interquartile range and lines for whiskers 11 | p + geom_tufteboxplot(median.type = "line") 12 | # combined with theme_tufte 13 | p + geom_tufteboxplot() + 14 | theme_tufte() + 15 | theme(axis.ticks.x = element_blank()) 16 | # traditional boxplot with whiskers only out to 1.5 IQR, outlier points 17 | p + geom_tufteboxplot(stat = "boxplot", outlier.shape = 5) 18 | -------------------------------------------------------------------------------- /inst/examples/ex-palette_pander.R: -------------------------------------------------------------------------------- 1 | \dontrun{ 2 | palette_pander(TRUE) 3 | } 4 | -------------------------------------------------------------------------------- /inst/examples/ex-ptol_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(ptol_pal()(6)) 4 | show_col(ptol_pal()(4)) 5 | show_col(ptol_pal()(12)) 6 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_color_tableau.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) + 6 | theme_igray() 7 | 8 | palettes <- ggthemes_data[["tableau"]][["color-palettes"]][["regular"]] 9 | for (palette in head(names(palettes), 3L)) { 10 | print(p + scale_colour_tableau(palette) + 11 | ggtitle(palette)) 12 | } 13 | 14 | # the order of colour can be reversed 15 | p + scale_color_tableau(direction = -1) 16 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_colour_excel_classic.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(gear))) + 4 | geom_point() + 5 | ggtitle("Cars") + 6 | theme_excel() + 7 | scale_colour_excel() 8 | 9 | ggplot(diamonds, aes(x = clarity, fill = cut)) + 10 | geom_bar() + 11 | scale_fill_excel() + 12 | theme_excel() 13 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_colour_excel_new.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(gear))) + 4 | geom_point() + 5 | ggtitle("Cars") + 6 | theme_excel_new() + 7 | scale_colour_excel_new() 8 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_colour_gradient2_tableau.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | df <- data.frame( 4 | x = runif(100), 5 | y = runif(100), 6 | z1 = rnorm(100), 7 | z2 = abs(rnorm(100)) 8 | ) 9 | p <- ggplot(df, aes(x, y)) + 10 | geom_point(aes(colour = z2)) 11 | 12 | palettes <- 13 | ggthemes_data[["tableau"]][["color-palettes"]][["ordered-diverging"]] 14 | for (palette in head(names(palettes))) { 15 | print(p + scale_colour_gradient2_tableau(palette) + 16 | ggtitle(palette)) 17 | } 18 | 19 | # If you need to reverse a palette, use a transformation 20 | p + scale_colour_gradient2_tableau(trans = "reverse") 21 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_colour_gradient_tableau.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | df <- data.frame( 4 | x = runif(100), 5 | y = runif(100), 6 | z1 = rnorm(100), 7 | z2 = abs(rnorm(100)) 8 | ) 9 | 10 | p <- ggplot(df, aes(x, y)) + 11 | geom_point(aes(colour = z2)) + 12 | theme_igray() 13 | 14 | palettes <- 15 | ggthemes_data[["tableau"]][["color-palettes"]][["ordered-sequential"]] 16 | for (palette in head(names(palettes))) { 17 | print(p + scale_colour_gradient_tableau(palette) + 18 | ggtitle(palette)) 19 | } 20 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_colour_ptol.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p2 <- ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(gear))) + 4 | geom_point() + 5 | geom_smooth(method = "lm", se = FALSE) + 6 | scale_color_ptol("cyl") + 7 | theme_minimal() + 8 | ggtitle("Cars") 9 | 10 | ggplot(diamonds, aes(x = clarity, fill = cut)) + 11 | geom_bar() + 12 | scale_fill_ptol() + 13 | theme_minimal() 14 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_linetype_stata.R: -------------------------------------------------------------------------------- 1 | require("ggplot2") 2 | if (require("tidyr") && require("dplyr")) { 3 | rescale01 <- function(x) { 4 | (x - min(x)) / diff(range(x)) 5 | } 6 | 7 | gather(economics, variable, value, -date) %>% 8 | group_by(variable) %>% 9 | mutate(value = rescale01(value)) %>% 10 | ggplot(aes(x = date, y = value, linetype = variable)) + 11 | geom_line() + 12 | scale_linetype_stata() 13 | } 14 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_shape_stata.R: -------------------------------------------------------------------------------- 1 | \dontrun{ 2 | library("ggplot2") 3 | 4 | p <- ggplot(mtcars) + 5 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 6 | facet_wrap(~am) 7 | p + theme_stata() + scale_shape_stata() 8 | } 9 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_shape_tableau.R: -------------------------------------------------------------------------------- 1 | \dontrun{ 2 | library("ggplot2") 3 | 4 | p <- ggplot(mtcars) + 5 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 6 | facet_wrap(~am) 7 | p + scale_shape_tableau() 8 | } 9 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_shape_tremmel.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars, aes(x = mpg, y = hp, shape = factor(cyl))) + 4 | geom_point() 5 | 6 | p + scale_shape_tremmel() 7 | p + scale_shape_tremmel(alt = TRUE) 8 | p + scale_shape_tremmel(overlap = TRUE) 9 | -------------------------------------------------------------------------------- /inst/examples/ex-scale_solarized.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) 6 | p + theme_solarized() + 7 | scale_colour_solarized() 8 | -------------------------------------------------------------------------------- /inst/examples/ex-show_linetypes.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_linetypes(linetype_pal()(3)) 4 | show_linetypes(linetype_pal()(3), labels = TRUE) 5 | -------------------------------------------------------------------------------- /inst/examples/ex-show_shapes.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_shapes(shape_pal()(5)) 4 | show_shapes(shape_pal()(3), labels = TRUE) 5 | -------------------------------------------------------------------------------- /inst/examples/ex-solarized_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(solarized_pal()(2)) 4 | show_col(solarized_pal()(3)) 5 | show_col(solarized_pal("red")(4)) 6 | -------------------------------------------------------------------------------- /inst/examples/ex-stata_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | show_col(stata_pal("s2color")(15)) 4 | show_col(stata_pal("s1rcolor")(15)) 5 | show_col(stata_pal("s1color")(15)) 6 | show_col(stata_pal("mono")(15)) 7 | -------------------------------------------------------------------------------- /inst/examples/ex-tableau_color_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | palettes <- ggthemes_data[["tableau"]][["color-palettes"]][["regular"]] 4 | for (palname in names(palettes)) { 5 | pal <- tableau_color_pal(palname) 6 | max_n <- attr(pal, "max_n") 7 | show_col(pal(max_n)) 8 | title(main = palname) 9 | } 10 | -------------------------------------------------------------------------------- /inst/examples/ex-tableau_div_gradient_pal.R: -------------------------------------------------------------------------------- 1 | x <- seq(-1, 1, length = 100) 2 | r <- sqrt(outer(x^2, x^2, "+")) 3 | 4 | palettes <- 5 | ggthemes_data[["tableau"]][["color-palettes"]][["ordered-diverging"]] 6 | for (palname in names(palettes)) { 7 | col <- tableau_div_gradient_pal(palname)(seq(0, 1, length = 12)) 8 | image(r, col = col) 9 | title(main = palname) 10 | } 11 | -------------------------------------------------------------------------------- /inst/examples/ex-tableau_seq_gradient_pal.R: -------------------------------------------------------------------------------- 1 | library("scales") 2 | 3 | x <- seq(0, 1, length = 25) 4 | r <- sqrt(outer(x^2, x^2, "+")) 5 | palettes <- 6 | ggthemes_data[["tableau"]][["color-palettes"]][["ordered-sequential"]] 7 | for (palname in names(palettes)) { 8 | col <- tableau_seq_gradient_pal(palname)(seq(0, 1, length = 12)) 9 | image(r, col = col) 10 | title(main = palname) 11 | } 12 | -------------------------------------------------------------------------------- /inst/examples/ex-tableau_shape_pal.R: -------------------------------------------------------------------------------- 1 | \dontrun{ 2 | # need to set a font containing these values 3 | show_shapes(tableau_shape_pal()(5)) 4 | } 5 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_base.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes( 5 | x = wt, y = mpg, 6 | colour = factor(gear) 7 | )) + 8 | facet_wrap(~am) 9 | p + theme_base() 10 | # Change values of par 11 | par(fg = "blue", bg = "gray", col.lab = "red", font.lab = 3) 12 | p + theme_base() 13 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_calc.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) + 6 | theme_calc() + 7 | scale_color_calc() 8 | \dontrun{ 9 | ggplot(mtcars) + 10 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 11 | facet_wrap(~am) + 12 | theme_calc() + 13 | scale_shape_calc() 14 | } 15 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_clean.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | p <- ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(gear))) + 3 | geom_point() + 4 | facet_wrap(~am) + 5 | geom_smooth(method = "lm", se = FALSE) + 6 | theme_clean() 7 | p 8 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_economist.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) + 6 | # Economist puts x-axis labels on the right-hand side 7 | scale_y_continuous(position = "right") 8 | 9 | ## Standard 10 | p + theme_economist() + 11 | scale_colour_economist() 12 | 13 | # Change axis lines to vertical 14 | p + theme_economist(horizontal = FALSE) + 15 | scale_colour_economist() + 16 | coord_flip() 17 | 18 | ## White panel/light gray background 19 | p + theme_economist_white() + 20 | scale_colour_economist() 21 | 22 | ## All white variant 23 | p + theme_economist_white(gray_bg = FALSE) + 24 | scale_colour_economist() 25 | 26 | \dontrun{ 27 | 28 | ## The Economist uses ITC Officina Sans 29 | library("extrafont") 30 | p + theme_economist(base_family="ITC Officina Sans") + 31 | scale_colour_economist() 32 | 33 | ## Verdana is a widely available substitute 34 | p + theme_economist(base_family="Verdana") + 35 | scale_colour_economist() 36 | 37 | } 38 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_excel.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | # Line and scatter plot colors 4 | p <- ggplot(mtcars) + 5 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 6 | facet_wrap(~am) 7 | p + theme_excel() + scale_colour_excel() 8 | 9 | # Bar plot (area/fill) colors 10 | ggplot(mpg, aes(x = class, fill = drv)) + 11 | geom_bar() + 12 | scale_fill_excel() + 13 | theme_excel() 14 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_excel_new.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) 6 | p + theme_excel_new() + scale_colour_excel_new() 7 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_few.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) 6 | p + theme_few() + scale_colour_few() 7 | p + theme_few() + scale_colour_few("Light") 8 | p + theme_few() + scale_colour_few("Dark") 9 | 10 | ggplot(mtcars) + 11 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 12 | theme_few() + 13 | scale_shape_few() 14 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_fivethirtyeight.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | p <- ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(gear))) + 3 | geom_point() + 4 | facet_wrap(~am) + 5 | geom_smooth(method = "lm", se = FALSE) + 6 | scale_color_fivethirtyeight() + 7 | theme_fivethirtyeight() 8 | p 9 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_gdocs.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) 6 | p + theme_gdocs() + scale_color_gdocs() 7 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_hc.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes( 5 | x = wt, y = mpg, 6 | colour = factor(gear) 7 | )) + 8 | facet_wrap(~am) 9 | p + theme_hc() + scale_colour_hc() 10 | p + theme_hc(bgcolor = "darkunica") + 11 | scale_colour_hc("darkunica") 12 | 13 | dtemp <- data.frame( 14 | months = factor(rep(substr(month.name, 1, 3), 4), 15 | levels = substr(month.name, 1, 3) 16 | ), 17 | city = rep(c("Tokyo", "New York", "Berlin", "London"), 18 | each = 12 19 | ), 20 | temp = c( 21 | 7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 22 | 25.2, 26.5, 23.3, 18.3, 13.9, 9.6, 23 | -0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24 | 24.8, 24.1, 20.1, 14.1, 8.6, 2.5, 25 | -0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 26 | 18.6, 17.9, 14.3, 9.0, 3.9, 1.0, 27 | 3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 28 | 17.0, 16.6, 14.2, 10.3, 6.6, 4.8 29 | ) 30 | ) 31 | 32 | ggplot(dtemp, aes(x = months, y = temp, group = city, color = city)) + 33 | geom_line() + 34 | geom_point(size = 1.1) + 35 | ggtitle("Monthly Average Temperature") + 36 | theme_hc() + 37 | scale_colour_hc() 38 | 39 | ggplot(dtemp, aes(x = months, y = temp, group = city, color = city)) + 40 | geom_line() + 41 | geom_point(size = 1.1) + 42 | ggtitle("Monthly Average Temperature") + 43 | theme_hc(bgcolor = "darkunica") + 44 | scale_fill_hc("darkunica") 45 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_igray.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) 6 | p + theme_igray() 7 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_map.R: -------------------------------------------------------------------------------- 1 | library("maps") 2 | library("ggplot2") 3 | 4 | us <- fortify(map_data("state"), region = "region") 5 | gg <- ggplot() + 6 | geom_map( 7 | data = us, map = us, 8 | aes(x = long, y = lat, map_id = region, group = group), 9 | fill = "white", color = "black", size = 0.25 10 | ) + 11 | coord_map("albers", lat0 = 39, lat1 = 45) + 12 | theme_map() 13 | gg 14 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_pander.R: -------------------------------------------------------------------------------- 1 | require("ggplot2") 2 | if (require("pander")) { 3 | p <- ggplot(mtcars, aes(x = mpg, y = wt)) + 4 | geom_point() 5 | p + theme_pander() 6 | 7 | panderOptions("graph.grid.color", "red") 8 | p + theme_pander() 9 | 10 | p <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + 11 | geom_point() 12 | p + theme_pander() + scale_color_pander() 13 | 14 | ggplot(mpg, aes(x = class, fill = drv)) + 15 | geom_bar() + 16 | scale_fill_pander() + 17 | theme_pander() 18 | } 19 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_par.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) 6 | 7 | p + theme_par() 8 | 9 | # theme changes with respect to values of par 10 | par(font = 2, col.lab = "red", fg = "white", bg = "black") 11 | p + theme_par() 12 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_solarized.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) 5 | 6 | # Light version with different main accent colors 7 | for (accent in names(ggthemes::ggthemes_data[["solarized"]][["accents"]])) { 8 | print(p + theme_solarized() + 9 | scale_colour_solarized(accent)) 10 | } 11 | 12 | # Dark version 13 | p + theme_solarized(light = FALSE) + 14 | scale_colour_solarized("blue") 15 | 16 | # Alternative theme 17 | p + theme_solarized_2(light = FALSE) + 18 | scale_colour_solarized("blue") 19 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_solid.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | ggplot(mtcars, aes(wt, mpg)) + 4 | geom_point() + 5 | theme_solid(fill = "white") 6 | 7 | ggplot(mtcars, aes(wt, mpg)) + 8 | geom_point(color = "white") + 9 | theme_solid(fill = "black") 10 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_stata.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) + 6 | labs( 7 | title = "Graphs by car type", 8 | x = "Weight (lbs.)", y = "MPG" 9 | ) 10 | 11 | # s2color 12 | p + theme_stata() + 13 | scale_colour_stata("s2color") 14 | # s2mono 15 | p + theme_stata(scheme = "s2mono") + 16 | scale_colour_stata("mono") 17 | # s1color 18 | p + theme_stata(scheme = "s2color") + 19 | scale_colour_stata("s1color") 20 | # s1rcolor 21 | p + theme_stata(scheme = "s1rcolor") + 22 | scale_colour_stata("s1rcolor") 23 | # s1mono 24 | p + theme_stata(scheme = "s1mono") + 25 | scale_colour_stata("mono") 26 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_tufte.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars, aes(x = wt, y = mpg)) + 4 | geom_point() + 5 | scale_x_continuous(breaks = extended_range_breaks()(mtcars$wt)) + 6 | scale_y_continuous(breaks = extended_range_breaks()(mtcars$mpg)) + 7 | ggtitle("Cars") 8 | 9 | p + geom_rangeframe() + 10 | coord_cartesian(clip = "off") + 11 | theme_tufte() 12 | 13 | p + geom_rug() + 14 | theme_tufte(ticks = FALSE) 15 | -------------------------------------------------------------------------------- /inst/examples/ex-theme_wsj.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | p <- ggplot(mtcars) + 4 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 5 | facet_wrap(~am) + 6 | ggtitle("Diamond Prices") 7 | p + scale_colour_wsj("colors6", "") + theme_wsj() 8 | # Use a gray background instead 9 | p + scale_colour_wsj("colors6", "") + theme_wsj(color = "gray") 10 | -------------------------------------------------------------------------------- /man/calc_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc.R 3 | \name{calc_pal} 4 | \alias{calc_pal} 5 | \title{Calc color palette (discrete)} 6 | \usage{ 7 | calc_pal() 8 | } 9 | \description{ 10 | Color palettes from LibreOffice Calc. 11 | This palette has 12 values. 12 | } 13 | \examples{ 14 | library("scales") 15 | 16 | show_col(calc_pal()(12)) 17 | } 18 | \seealso{ 19 | Other colour calc: 20 | \code{\link{scale_fill_calc}()} 21 | } 22 | \concept{colour calc} 23 | -------------------------------------------------------------------------------- /man/calc_shape_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc.R 3 | \name{calc_shape_pal} 4 | \alias{calc_shape_pal} 5 | \title{Calc shape palette (discrete)} 6 | \usage{ 7 | calc_shape_pal() 8 | } 9 | \description{ 10 | Shape palette based on the shapes used in LibreOffice Calc. 11 | } 12 | \examples{ 13 | \dontrun{ 14 | library("ggplot2") 15 | show_shapes(calc_shape_pal()(13)) 16 | } 17 | } 18 | \seealso{ 19 | Other shapes calc: 20 | \code{\link{scale_shape_calc}()} 21 | } 22 | \concept{shapes calc} 23 | -------------------------------------------------------------------------------- /man/canva_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/canva.R 3 | \name{canva_pal} 4 | \alias{canva_pal} 5 | \title{Canva.com color palettes} 6 | \usage{ 7 | canva_pal(palette = "Fresh and bright") 8 | } 9 | \arguments{ 10 | \item{palette}{Palette name. See the names of \code{\link{canva_palettes}()} 11 | for valid names.} 12 | } 13 | \value{ 14 | A function that takes a single value, the number of colors to use. 15 | } 16 | \description{ 17 | 150+ color palettes from canva.com. See \code{\link{canva_palettes}()}. 18 | } 19 | \examples{ 20 | require("ggplot2") 21 | require("tibble") 22 | if (require("purrr") && require("scales") && require("dplyr")) { 23 | canva_df <- map2_df( 24 | canva_palettes, 25 | names(canva_palettes), 26 | ~ tibble( 27 | colors = .x, 28 | .id = seq_along(colors), 29 | palette = .y 30 | ) 31 | ) 32 | ggplot(canva_df, aes( 33 | y = palette, 34 | x = .id, 35 | fill = colors 36 | )) + 37 | geom_raster() + 38 | scale_fill_identity(guide = FALSE) + 39 | theme_minimal() + 40 | theme( 41 | panel.grid = element_blank(), 42 | axis.text.x = element_blank() 43 | ) + 44 | labs(x = "", y = "") 45 | 46 | show_col(canva_pal("Fresh and bright")(4)) 47 | show_col(canva_pal("Cool blues")(4)) 48 | show_col(canva_pal("Modern and crisp")(4)) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /man/canva_palettes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/canva.R 3 | \docType{data} 4 | \name{canva_palettes} 5 | \alias{canva_palettes} 6 | \title{150 Color Palettes from Canva} 7 | \format{ 8 | A named \code{list} of character vector. 9 | The names are the palette names. The values of the character vectors 10 | are hex colors, e.g. \code{"#f98866"}. 11 | } 12 | \usage{ 13 | canva_palettes 14 | } 15 | \description{ 16 | 150 four-color palettes by the 17 | \href{https://www.canva.com/learn/}{canva.com} design school. 18 | These palettes were derived from photos and "impactful websites". 19 | } 20 | \examples{ 21 | require("ggplot2") 22 | require("tibble") 23 | if (require("purrr") && require("scales") && require("dplyr")) { 24 | canva_df <- map2_df( 25 | canva_palettes, 26 | names(canva_palettes), 27 | ~ tibble( 28 | colors = .x, 29 | .id = seq_along(colors), 30 | palette = .y 31 | ) 32 | ) 33 | ggplot(canva_df, aes( 34 | y = palette, 35 | x = .id, 36 | fill = colors 37 | )) + 38 | geom_raster() + 39 | scale_fill_identity(guide = FALSE) + 40 | theme_minimal() + 41 | theme( 42 | panel.grid = element_blank(), 43 | axis.text.x = element_blank() 44 | ) + 45 | labs(x = "", y = "") 46 | 47 | show_col(canva_pal("Fresh and bright")(4)) 48 | show_col(canva_pal("Cool blues")(4)) 49 | show_col(canva_pal("Modern and crisp")(4)) 50 | } 51 | } 52 | \references{ 53 | \itemize{ 54 | \item{Janie Kliever, \href{https://www.canva.com/learn/100-color-combinations/}{100 Brilliant Color Combinations and How to Apply Them to Your Designs}, 55 | \emph{Canva.com}, June 20, 2015.} 56 | \item{Mary Stribley, \href{https://www.canva.com/learn/website-color-schemes/}{Website Color Schemes: The Palettes of 50 Visually Impactful Websites to Inspire You}, 57 | \emph{Canva.com}, January 26, 2016.} 58 | \item{Schwabish, Jonathan. 59 | \href{https://policyviz.com/2017/01/12/150-color-palettes-for-excel/}{150+ Color Palettes for Excel}, 60 | \emph{PolicyViz}, January 12, 2017.} 61 | } 62 | } 63 | \keyword{datasets} 64 | -------------------------------------------------------------------------------- /man/circlefill_shape_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/shapes.R 3 | \name{circlefill_shape_pal} 4 | \alias{circlefill_shape_pal} 5 | \title{Filled Circle Shape palette (discrete)} 6 | \usage{ 7 | circlefill_shape_pal() 8 | } 9 | \description{ 10 | `r lifecycle::badge("deprecated")` 11 | 12 | This function was deprecated because unicode glyphs used for the circles 13 | vary in size, making them unusable for plotting. 14 | 15 | Shape palette with circles varying by amount of fill. This uses 16 | the set of 3 circle fill values in Lewandowsky and Spence (1989): 17 | solid, hollow, half-filled, with two additional fill amounts: 18 | three-quarters, and one-quarter. 19 | 20 | This palette supports up to five values. 21 | } 22 | \references{ 23 | Lewandowsky, Stephan and Ian Spence (1989) 24 | "Discriminating Strata in Scatterplots", Journal of 25 | the American Statistical Association, \url{https://www.jstor.org/stable/2289649} 26 | } 27 | \seealso{ 28 | Other shapes: 29 | \code{\link{cleveland_shape_pal}()}, 30 | \code{\link{scale_shape_circlefill}()}, 31 | \code{\link{scale_shape_cleveland}()}, 32 | \code{\link{scale_shape_tremmel}()}, 33 | \code{\link{tremmel_shape_pal}()} 34 | } 35 | \concept{shapes} 36 | -------------------------------------------------------------------------------- /man/cleveland_shape_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/shapes.R 3 | \name{cleveland_shape_pal} 4 | \alias{cleveland_shape_pal} 5 | \title{Shape palette from Cleveland "Elements of Graphing Data" (discrete).} 6 | \usage{ 7 | cleveland_shape_pal(overlap = TRUE) 8 | } 9 | \arguments{ 10 | \item{overlap}{\code{logical} Use the scale for overlapping points?} 11 | } 12 | \description{ 13 | Shape palettes for overlapping and non-overlapping points. 14 | } 15 | \note{ 16 | In the \emph{Elements of Graphing Data}, W.S. Cleveland suggests 17 | two shape palettes for scatter plots: one for overlapping data and 18 | another for non-overlapping data. The symbols for overlapping data 19 | relies on pattern discrimination, while the symbols for 20 | non-overlapping data vary the amount of fill. This palette 21 | attempts to create these palettes. However, I found that these 22 | were hard to replicate. Using the R shapes and unicode fonts: the 23 | symbols can vary in size, they are dependent of the fonts used, 24 | and there does not exist a unicode symbol for a circle with a 25 | vertical line. If someone can improve this palette, please let me 26 | know. 27 | 28 | Following Tremmel (1995), I replace the circle with a vertical 29 | line with an encircled plus sign. 30 | 31 | The palette \code{cleveland_shape_pal()} supports up to five values. 32 | } 33 | \examples{ 34 | ### (discrete). 35 | 36 | \dontrun{ 37 | library("ggplot2") 38 | p <- ggplot(mtcars) + 39 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 40 | facet_wrap(~am) + 41 | theme_bw() 42 | # overlapping symbol palette 43 | p + scale_shape_cleveland() 44 | # non-overlapping symbol palette 45 | p + scale_shape_cleveland(overlap = FALSE) 46 | } 47 | } 48 | \references{ 49 | Cleveland WS. \emph{The Elements of Graphing Data}. Revised Edition. Hobart Press, Summit, NJ, 1994, pp. 154-164, 234-239. 50 | 51 | Tremmel, Lothar, (1995) "The Visual Separability of Plotting Symbols in Scatterplots", \emph{Journal of Computational and Graphical Statistics}, 52 | \url{https://www.jstor.org/stable/1390760} 53 | } 54 | \seealso{ 55 | Other shapes: 56 | \code{\link{circlefill_shape_pal}()}, 57 | \code{\link{scale_shape_circlefill}()}, 58 | \code{\link{scale_shape_cleveland}()}, 59 | \code{\link{scale_shape_tremmel}()}, 60 | \code{\link{tremmel_shape_pal}()} 61 | } 62 | \concept{shapes} 63 | -------------------------------------------------------------------------------- /man/economist_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/economist.R 3 | \name{economist_pal} 4 | \alias{economist_pal} 5 | \title{Economist color palette (discrete)} 6 | \usage{ 7 | economist_pal(fill = TRUE) 8 | } 9 | \arguments{ 10 | \item{fill}{Use the fill palette.} 11 | } 12 | \description{ 13 | The hues in the palette are blues, grays, and greens. Red is not 14 | included in these palettes and should be used to indicate 15 | important data. 16 | } 17 | \examples{ 18 | library("scales") 19 | 20 | show_col(economist_pal()(6)) 21 | ## fill palette 22 | show_col(economist_pal(fill = TRUE)(6)) 23 | } 24 | \seealso{ 25 | Other colour economist: 26 | \code{\link{scale_colour_economist}()} 27 | } 28 | \concept{colour economist} 29 | -------------------------------------------------------------------------------- /man/excel_new_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/excel.R 3 | \name{excel_new_pal} 4 | \alias{excel_new_pal} 5 | \title{Excel (current versions) color palettes (discrete)} 6 | \usage{ 7 | excel_new_pal(theme = "Office Theme") 8 | } 9 | \arguments{ 10 | \item{theme}{The name of the Office theme or color theme 11 | (not to be confused with ggplot2 themes) from which to derive the color 12 | palette. Available themes include: 13 | \Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$excel$themes))}} 14 | } 15 | \description{ 16 | Color palettes used by current versions of Microsoft Office and Excel. 17 | } 18 | \examples{ 19 | library("scales") 20 | 21 | for (i in names(ggthemes::ggthemes_data$excel$palettes)) { 22 | show_col(excel_new_pal(theme = i))(6) 23 | } 24 | } 25 | \seealso{ 26 | Other colour excel: 27 | \code{\link{excel_pal}()}, 28 | \code{\link{scale_colour_excel_new}()}, 29 | \code{\link{scale_fill_excel}()} 30 | } 31 | \concept{colour excel} 32 | -------------------------------------------------------------------------------- /man/excel_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/excel.R 3 | \name{excel_pal} 4 | \alias{excel_pal} 5 | \title{Excel 97 ugly color palettes (discrete)} 6 | \usage{ 7 | excel_pal(line = TRUE) 8 | } 9 | \arguments{ 10 | \item{line}{If \code{TRUE}, use the palette for lines and points. Otherwise, 11 | use the palette for area.} 12 | } 13 | \description{ 14 | The color palettes used in Microsoft Excel 97 (and up until Excel 2007). 15 | Use this for that classic ugly look and feel. For ironic purposes only. 16 | 3D bars and pies not included. Please never use this color palette. 17 | } 18 | \examples{ 19 | library("scales") 20 | 21 | show_col(excel_pal()(7)) 22 | show_col(excel_pal(line = FALSE)(7)) 23 | } 24 | \seealso{ 25 | Other colour excel: 26 | \code{\link{excel_new_pal}()}, 27 | \code{\link{scale_colour_excel_new}()}, 28 | \code{\link{scale_fill_excel}()} 29 | } 30 | \concept{colour excel} 31 | -------------------------------------------------------------------------------- /man/few_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/few.R 3 | \name{few_pal} 4 | \alias{few_pal} 5 | \title{Color Palettes Few "Show Me the Numbers"} 6 | \usage{ 7 | few_pal(palette = "Medium") 8 | } 9 | \arguments{ 10 | \item{palette}{One of \Sexpr[results=rd]{names(ggthemes:::rd_optlist(ggthemes::ggthemes_data$few$colors))}} 11 | } 12 | \description{ 13 | Qualitative color palettes from Stephen Few (2012) 14 | \emph{Show Me the Numbers}. There are three palettes: 15 | Light, Medium, and Dark. Each palette comprises nine colors: 16 | gray, blue, orange, green, pink, brown, purple, yellow, red. 17 | For \code{n = 1}, gray is used. For \code{n > 1}, the eight non-gray 18 | colors are used. 19 | } 20 | \details{ 21 | Use the light palette for filled areas, such as bar charts. 22 | Use the medium palette for points and lines. 23 | Use the dark palette for highlighting specific points 24 | or for small and thin lines and points. 25 | } 26 | \examples{ 27 | library("scales") 28 | 29 | show_col(few_pal()(7)) 30 | show_col(few_pal("Dark")(7)) 31 | show_col(few_pal("Light")(7)) 32 | } 33 | \references{ 34 | Few, S. (2012) \emph{Show Me the Numbers: Designing Tables and Graphs to Enlighten}. 35 | 2nd edition. Analytics Press. 36 | 37 | \href{https://www.perceptualedge.com/articles/visual_business_intelligence/rules_for_using_color.pdf}{"Practical Rules for Using Color in Charts"}. 38 | } 39 | \seealso{ 40 | Other colour few: 41 | \code{\link{scale_colour_few}()} 42 | } 43 | \concept{colour few} 44 | -------------------------------------------------------------------------------- /man/few_shape_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/few.R 3 | \name{few_shape_pal} 4 | \alias{few_shape_pal} 5 | \title{Shape palette from "Show Me the Numbers" (discrete)} 6 | \usage{ 7 | few_shape_pal() 8 | } 9 | \description{ 10 | Shape palette from Stephen Few's, "Show Me the Numbers". 11 | The shape palette consists of five shapes: circle, square, triangle, plus, 12 | times. 13 | } 14 | \references{ 15 | Few, S. (2012) 16 | \emph{Show Me the Numbers: Designing Tables and Graphs to Enlighten}, 17 | Analytics Press, p. 208. 18 | } 19 | -------------------------------------------------------------------------------- /man/figures/README-scale_color_tableau-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-scale_color_tableau-1.png -------------------------------------------------------------------------------- /man/figures/README-scale_colorblind-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-scale_colorblind-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_calc-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_calc-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_clean-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_clean-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_economist-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_economist-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_excel-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_excel-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_excel_new-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_excel_new-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_few-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_few-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_fivethirtyeight-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_fivethirtyeight-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_igray-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_igray-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_par-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_par-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_solarized-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_solarized-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_solarized_dark-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_solarized_dark-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_solid-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_solid-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_stata-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_stata-1.png -------------------------------------------------------------------------------- /man/figures/README-theme_wsj-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrnold/ggthemes/ca38c6250b17acc138b5cd5ccc45ab9e07234f3a/man/figures/README-theme_wsj-1.png -------------------------------------------------------------------------------- /man/fivethirtyeight_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fivethirtyeight.R 3 | \name{fivethirtyeight_pal} 4 | \alias{fivethirtyeight_pal} 5 | \title{FiveThirtyEight color palette} 6 | \usage{ 7 | fivethirtyeight_pal() 8 | } 9 | \description{ 10 | The standard three-color FiveThirtyEight palette for line plots comprises 11 | blue, red, and green. 12 | } 13 | \examples{ 14 | library("scales") 15 | 16 | show_col(fivethirtyeight_pal()(3)) 17 | } 18 | \seealso{ 19 | Other colour fivethirtyeight: 20 | \code{\link{scale_colour_fivethirtyeight}()} 21 | } 22 | \concept{colour fivethirtyeight} 23 | -------------------------------------------------------------------------------- /man/gdocs_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gdocs.R 3 | \name{gdocs_pal} 4 | \alias{gdocs_pal} 5 | \title{Google Docs color palette (discrete)} 6 | \usage{ 7 | gdocs_pal() 8 | } 9 | \description{ 10 | Color palettes from Google Docs. 11 | This palette includes 20 colors. 12 | } 13 | \examples{ 14 | library("scales") 15 | 16 | show_col(gdocs_pal()(24)) 17 | } 18 | \seealso{ 19 | Other colour gdocs: 20 | \code{\link{scale_fill_gdocs}()} 21 | } 22 | \concept{colour gdocs} 23 | -------------------------------------------------------------------------------- /man/ggthemes-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ggthemes-package.R 3 | \docType{package} 4 | \name{ggthemes-package} 5 | \alias{ggthemes} 6 | \alias{ggthemes-package} 7 | \title{ggthemes: Extra Themes, Scales and Geoms for 'ggplot2'} 8 | \description{ 9 | Some extra themes, geoms, and scales for 'ggplot2'. Provides 'ggplot2' themes and scales that replicate the look of plots by Edward Tufte, Stephen Few, 'Fivethirtyeight', 'The Economist', 'Stata', 'Excel', and 'The Wall Street Journal', among others. Provides 'geoms' for Tufte's box plot and range frame. 10 | } 11 | \seealso{ 12 | Useful links: 13 | \itemize{ 14 | \item \url{https://jrnold.github.io/ggthemes/} 15 | \item \url{https://github.com/jrnold/ggthemes} 16 | \item Report bugs at \url{https://github.com/jrnold/ggthemes/issues} 17 | } 18 | 19 | } 20 | \author{ 21 | \strong{Maintainer}: Jeffrey B. Arnold \email{jeffrey.arnold@gmail.com} () 22 | 23 | Other contributors: 24 | \itemize{ 25 | \item Gergely Daroczi [contributor] 26 | \item Bo Werth [contributor] 27 | \item Brian Weitzner [contributor] 28 | \item Joshua Kunst [contributor] 29 | \item Baptise Auguie [contributor] 30 | \item Bob Rudis [contributor] 31 | \item Hadley Wickham (Code from the ggplot2 package.) [contributor] 32 | \item Justin Talbot (Code from the labeling package) [contributor] 33 | \item Joshua London [contributor] 34 | } 35 | 36 | } 37 | \keyword{internal} 38 | -------------------------------------------------------------------------------- /man/ggthemes_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ggthemes_data.R 3 | \docType{data} 4 | \name{ggthemes_data} 5 | \alias{ggthemes_data} 6 | \title{Palette and theme data} 7 | \format{ 8 | A \code{list} object. 9 | } 10 | \usage{ 11 | ggthemes_data 12 | } 13 | \description{ 14 | The \code{ggthemes} environment contains various values used in 15 | themes and palettes. This is undocumented and subject to change. 16 | } 17 | \keyword{datasets} 18 | -------------------------------------------------------------------------------- /man/hc_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hc.R 3 | \name{hc_pal} 4 | \alias{hc_pal} 5 | \title{Highcharts color palette (discrete)} 6 | \usage{ 7 | hc_pal(palette = "default") 8 | } 9 | \arguments{ 10 | \item{palette}{\code{character} The name of the Highcharts theme to use. One of 11 | \code{"default"}, or \code{"darkunica"}.} 12 | } 13 | \description{ 14 | The Highcharts uses many different color palettes in its 15 | plots. This collects a few of them. 16 | } 17 | \seealso{ 18 | Other colour hc: 19 | \code{\link{scale_colour_hc}()} 20 | } 21 | \concept{colour hc} 22 | -------------------------------------------------------------------------------- /man/macros/funclink.Rd: -------------------------------------------------------------------------------- 1 | \newcommand{\funclink}{\code{\link[=#1]{#1()}}} 2 | -------------------------------------------------------------------------------- /man/palette_pander.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pander.R 3 | \name{palette_pander} 4 | \alias{palette_pander} 5 | \title{Color palette from the pander package} 6 | \usage{ 7 | palette_pander(n, random_order = FALSE) 8 | } 9 | \arguments{ 10 | \item{n}{number of colors. This palette supports up to eight colors.} 11 | 12 | \item{random_order}{if the palette should be reordered randomly before 13 | rendering each plot to get colorful images} 14 | } 15 | \description{ 16 | The \pkg{pander} ships with a default colorblind and printer-friendly 17 | color palette borrowed from \verb{https://jfly.iam.u-tokyo.ac.jp/color/}. 18 | } 19 | \examples{ 20 | \dontrun{ 21 | palette_pander(TRUE) 22 | } 23 | } 24 | \seealso{ 25 | Other colour pander: 26 | \code{\link{scale_color_pander}()} 27 | } 28 | \concept{colour pander} 29 | -------------------------------------------------------------------------------- /man/ptol_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/ptol.R 3 | \name{ptol_pal} 4 | \alias{ptol_pal} 5 | \title{Color Palettes from Paul Tol's "Colour Schemes"} 6 | \usage{ 7 | ptol_pal() 8 | } 9 | \description{ 10 | Qualitative color palettes from Paul Tol, 11 | \href{https://personal.sron.nl/~pault/}{"Colour Schemes"}. 12 | } 13 | \details{ 14 | Incorporation of the palette into an R package was originally inspired by 15 | Peter Carl's [Paul Tol 21 Gun Salute](https://tradeblotter.wordpress.com/2013/02/28/the-paul-tol-21-color-salute/) 16 | } 17 | \examples{ 18 | library("scales") 19 | 20 | show_col(ptol_pal()(6)) 21 | show_col(ptol_pal()(4)) 22 | show_col(ptol_pal()(12)) 23 | } 24 | \references{ 25 | Paul Tol. 2012. "Colour Schemes." SRON Technical Note, SRON/EPS/TN/09-002. 26 | \url{https://personal.sron.nl/~pault/data/colourschemes.pdf} 27 | } 28 | \seealso{ 29 | Other colour ptol: 30 | \code{\link{scale_colour_ptol}()} 31 | } 32 | \concept{colour ptol} 33 | -------------------------------------------------------------------------------- /man/range_breaks.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/scales.R 3 | \name{extended_range_breaks_} 4 | \alias{extended_range_breaks_} 5 | \alias{extended_range_breaks} 6 | \title{Pretty axis breaks inclusive of extreme values} 7 | \usage{ 8 | extended_range_breaks_( 9 | dmin, 10 | dmax, 11 | n = 5, 12 | Q = c(1, 5, 2, 2.5, 4, 3), 13 | w = c(0.25, 0.2, 0.5, 0.05) 14 | ) 15 | 16 | extended_range_breaks(n = 5, ...) 17 | } 18 | \arguments{ 19 | \item{dmin}{minimum of the data range} 20 | 21 | \item{dmax}{maximum of the data range} 22 | 23 | \item{n}{desired number of breaks} 24 | 25 | \item{Q}{set of nice numbers} 26 | 27 | \item{w}{weights applied to the four optimization components (simplicity, coverage, density, and legibility)} 28 | 29 | \item{...}{other arguments passed to \code{extended_range_breaks_()}} 30 | } 31 | \value{ 32 | For \code{extended_range_breaks}, the vector of axis label locations. 33 | For \code{scales_extended_range_breaks}, a function which takes a single argument, a vector of data, and returns 34 | the vector of axis label locations. 35 | 36 | A function which returns breaks given a vector. 37 | } 38 | \description{ 39 | This function returns pretty axis breaks that always include the extreme values of the data. 40 | This works by calling the extended Wilkinson algorithm (Talbot et al., 2010), constrained to solutions 41 | interior to the data range. 42 | Then, the minimum and maximum labels are moved to the minimum and maximum of the data 43 | range. 44 | } 45 | \details{ 46 | \code{extended_range_breaks} implements the algorithm and returns the break values. 47 | \code{scales_extended_range_breaks} uses the conventions of the \pkg{scales} package, and returns a function. 48 | } 49 | \references{ 50 | Talbot, J., Lin, S., Hanrahan, P. (2010) An Extension of Wilkinson's Algorithm 51 | for Positioning Tick Labels on Axes, InfoVis 2010. 52 | } 53 | \author{ 54 | Justin Talbot \email{jtalbot@stanford.edu}, Jeffrey B. Arnold, Baptiste Auguie 55 | } 56 | -------------------------------------------------------------------------------- /man/scale_color_tableau.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tableau.R 3 | \name{scale_colour_tableau} 4 | \alias{scale_colour_tableau} 5 | \alias{scale_fill_tableau} 6 | \alias{scale_color_tableau} 7 | \title{Tableau color scales (discrete)} 8 | \usage{ 9 | scale_colour_tableau( 10 | palette = "Tableau 10", 11 | type = "regular", 12 | direction = 1, 13 | ... 14 | ) 15 | 16 | scale_fill_tableau( 17 | palette = "Tableau 10", 18 | type = "regular", 19 | direction = 1, 20 | ... 21 | ) 22 | 23 | scale_color_tableau( 24 | palette = "Tableau 10", 25 | type = "regular", 26 | direction = 1, 27 | ... 28 | ) 29 | } 30 | \arguments{ 31 | \item{palette}{Palette name. See \funclink{tableau_color_pal} 32 | for available palettes.} 33 | 34 | \item{type}{Palette type. One of \code{"regular"}, \code{"sequential"}, 35 | or \code{"diverging"}. See \funclink{tableau_color_pal}.} 36 | 37 | \item{direction}{If 1, the default, then use the original order of 38 | colors. If -1, then reverse the order.} 39 | 40 | \item{...}{Other arguments passed on to \funclink{discrete_scale}.} 41 | } 42 | \description{ 43 | Categorical (qualitative) color scales used in Tableau. 44 | Use the function \funclink{scale_colour_gradient_tableau} for the sequential 45 | and \funclink{scale_colour_gradient2_tableau} for the diverging continuous 46 | color scales from Tableu. 47 | } 48 | \examples{ 49 | library("ggplot2") 50 | 51 | p <- ggplot(mtcars) + 52 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 53 | facet_wrap(~am) + 54 | theme_igray() 55 | 56 | palettes <- ggthemes_data[["tableau"]][["color-palettes"]][["regular"]] 57 | for (palette in head(names(palettes), 3L)) { 58 | print(p + scale_colour_tableau(palette) + 59 | ggtitle(palette)) 60 | } 61 | 62 | # the order of colour can be reversed 63 | p + scale_color_tableau(direction = -1) 64 | } 65 | \seealso{ 66 | \code{\link{tableau_color_pal}()} for references. 67 | 68 | Other colour tableau: 69 | \code{\link{scale_colour_gradient2_tableau}()}, 70 | \code{\link{scale_colour_gradient_tableau}()}, 71 | \code{\link{tableau_color_pal}()}, 72 | \code{\link{tableau_gradient_pal}()} 73 | } 74 | \concept{colour tableau} 75 | -------------------------------------------------------------------------------- /man/scale_colour_canva.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/canva.R 3 | \name{scale_colour_canva} 4 | \alias{scale_colour_canva} 5 | \alias{scale_color_canva} 6 | \alias{scale_fill_canva} 7 | \title{Discrete color scale using canva.com color palettes} 8 | \usage{ 9 | scale_colour_canva(..., palette = "Fresh and bright") 10 | 11 | scale_color_canva(..., palette = "Fresh and bright") 12 | 13 | scale_fill_canva(..., palette = "Fresh and bright") 14 | } 15 | \arguments{ 16 | \item{...}{Arguments passed to \code{\link{discrete_scale}()}.} 17 | 18 | \item{palette}{Palette name. See the names of \code{\link{canva_palettes}()} 19 | for valid names.} 20 | } 21 | \description{ 22 | Color scale for canva.com color palettes described in 23 | \code{\link{canva_palettes}()}. 24 | } 25 | -------------------------------------------------------------------------------- /man/scale_colour_gradient2_tableau.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tableau.R 3 | \name{scale_colour_gradient2_tableau} 4 | \alias{scale_colour_gradient2_tableau} 5 | \alias{scale_fill_gradient2_tableau} 6 | \alias{scale_color_gradient2_tableau} 7 | \title{Tableau diverging colour scales (continuous)} 8 | \usage{ 9 | scale_colour_gradient2_tableau( 10 | palette = "Orange-Blue Diverging", 11 | ..., 12 | na.value = "grey50", 13 | guide = "colourbar" 14 | ) 15 | 16 | scale_fill_gradient2_tableau( 17 | palette = "Orange-Blue Diverging", 18 | ..., 19 | na.value = "grey50", 20 | guide = "colourbar" 21 | ) 22 | 23 | scale_color_gradient2_tableau( 24 | palette = "Orange-Blue Diverging", 25 | ..., 26 | na.value = "grey50", 27 | guide = "colourbar" 28 | ) 29 | } 30 | \arguments{ 31 | \item{palette}{Palette name. 32 | \describe{ 33 | \item{\code{"ordered-sequential"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["ordered-sequential"]]))}} 34 | \item{\code{"ordered-diverging"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["ordered-diverging"]]))}} 35 | }} 36 | 37 | \item{...}{Arguments passed to \code{tableau_gradient_pal}.} 38 | 39 | \item{na.value}{Colour to use for missing values} 40 | 41 | \item{guide}{Type of legend. Use \code{'colourbar'} for continuous 42 | colour bar, or \code{'legend'} for discrete colour legend.} 43 | } 44 | \description{ 45 | Continuous color scales using the diverging color scales in Tableau. 46 | See \funclink{scale_colour_tableau} for Tabaleau discrete color scales, 47 | and \funclink{scale_colour_gradient_tableau} for sequential color scales. 48 | } 49 | \examples{ 50 | library("ggplot2") 51 | 52 | df <- data.frame( 53 | x = runif(100), 54 | y = runif(100), 55 | z1 = rnorm(100), 56 | z2 = abs(rnorm(100)) 57 | ) 58 | p <- ggplot(df, aes(x, y)) + 59 | geom_point(aes(colour = z2)) 60 | 61 | palettes <- 62 | ggthemes_data[["tableau"]][["color-palettes"]][["ordered-diverging"]] 63 | for (palette in head(names(palettes))) { 64 | print(p + scale_colour_gradient2_tableau(palette) + 65 | ggtitle(palette)) 66 | } 67 | 68 | # If you need to reverse a palette, use a transformation 69 | p + scale_colour_gradient2_tableau(trans = "reverse") 70 | } 71 | \seealso{ 72 | Other colour tableau: 73 | \code{\link{scale_colour_gradient_tableau}()}, 74 | \code{\link{scale_colour_tableau}()}, 75 | \code{\link{tableau_color_pal}()}, 76 | \code{\link{tableau_gradient_pal}()} 77 | } 78 | \concept{colour tableau} 79 | -------------------------------------------------------------------------------- /man/scale_colour_gradient_tableau.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tableau.R 3 | \name{scale_colour_gradient_tableau} 4 | \alias{scale_colour_gradient_tableau} 5 | \alias{scale_fill_gradient_tableau} 6 | \alias{scale_color_gradient_tableau} 7 | \alias{scale_color_continuous_tableau} 8 | \alias{scale_fill_continuous_tableau} 9 | \title{Tableau sequential colour scales (continuous)} 10 | \usage{ 11 | scale_colour_gradient_tableau( 12 | palette = "Blue", 13 | ..., 14 | na.value = "grey50", 15 | guide = "colourbar" 16 | ) 17 | 18 | scale_fill_gradient_tableau( 19 | palette = "Blue", 20 | ..., 21 | na.value = "grey50", 22 | guide = "colourbar" 23 | ) 24 | 25 | scale_color_gradient_tableau( 26 | palette = "Blue", 27 | ..., 28 | na.value = "grey50", 29 | guide = "colourbar" 30 | ) 31 | 32 | scale_color_continuous_tableau( 33 | palette = "Blue", 34 | ..., 35 | na.value = "grey50", 36 | guide = "colourbar" 37 | ) 38 | 39 | scale_fill_continuous_tableau( 40 | palette = "Blue", 41 | ..., 42 | na.value = "grey50", 43 | guide = "colourbar" 44 | ) 45 | } 46 | \arguments{ 47 | \item{palette}{Palette name. 48 | \describe{ 49 | \item{\code{"ordered-sequential"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["ordered-sequential"]]))}} 50 | \item{\code{"ordered-diverging"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["ordered-diverging"]]))}} 51 | }} 52 | 53 | \item{...}{Arguments passed to \code{tableau_gradient_pal}.} 54 | 55 | \item{na.value}{Colour to use for missing values} 56 | 57 | \item{guide}{Type of legend. Use \code{'colourbar'} for continuous 58 | colour bar, or \code{'legend'} for discrete colour legend.} 59 | } 60 | \description{ 61 | Continuous color scales using the sequential color palettes in Tableau. 62 | See \funclink{scale_colour_tableau} for Tableau discrete color scales, 63 | and \funclink{scale_colour_gradient2_tableau} for diverging color 64 | scales. 65 | } 66 | \examples{ 67 | library("ggplot2") 68 | 69 | df <- data.frame( 70 | x = runif(100), 71 | y = runif(100), 72 | z1 = rnorm(100), 73 | z2 = abs(rnorm(100)) 74 | ) 75 | 76 | p <- ggplot(df, aes(x, y)) + 77 | geom_point(aes(colour = z2)) + 78 | theme_igray() 79 | 80 | palettes <- 81 | ggthemes_data[["tableau"]][["color-palettes"]][["ordered-sequential"]] 82 | for (palette in head(names(palettes))) { 83 | print(p + scale_colour_gradient_tableau(palette) + 84 | ggtitle(palette)) 85 | } 86 | } 87 | \seealso{ 88 | Other colour tableau: 89 | \code{\link{scale_colour_gradient2_tableau}()}, 90 | \code{\link{scale_colour_tableau}()}, 91 | \code{\link{tableau_color_pal}()}, 92 | \code{\link{tableau_gradient_pal}()} 93 | } 94 | \concept{colour tableau} 95 | -------------------------------------------------------------------------------- /man/scale_shape_calc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc.R 3 | \name{scale_shape_calc} 4 | \alias{scale_shape_calc} 5 | \title{Calc shape scale} 6 | \usage{ 7 | scale_shape_calc(...) 8 | } 9 | \arguments{ 10 | \item{...}{ 11 | Arguments passed on to \code{\link[ggplot2:discrete_scale]{discrete_scale}} 12 | \describe{ 13 | \item{\code{palette}}{A palette function that when called with a single integer 14 | argument (the number of levels in the scale) returns the values that 15 | they should take (e.g., \code{\link[scales:hue_pal]{scales::hue_pal()}}).} 16 | \item{\code{breaks}}{One of: 17 | \itemize{ 18 | \item \code{NULL} for no breaks 19 | \item \code{waiver()} for the default breaks (the scale limits) 20 | \item A character vector of breaks 21 | \item A function that takes the limits as input and returns breaks 22 | as output. Also accepts rlang \link[rlang:as_function]{lambda} function 23 | notation. 24 | }} 25 | \item{\code{limits}}{One of: 26 | \itemize{ 27 | \item \code{NULL} to use the default scale values 28 | \item A character vector that defines possible values of the scale and their 29 | order 30 | \item A function that accepts the existing (automatic) values and returns 31 | new ones. Also accepts rlang \link[rlang:as_function]{lambda} function 32 | notation. 33 | }} 34 | \item{\code{drop}}{Should unused factor levels be omitted from the scale? 35 | The default, \code{TRUE}, uses the levels that appear in the data; 36 | \code{FALSE} uses all the levels in the factor.} 37 | \item{\code{na.translate}}{Unlike continuous scales, discrete scales can easily show 38 | missing values, and do so by default. If you want to remove missing values 39 | from a discrete scale, specify \code{na.translate = FALSE}.} 40 | \item{\code{na.value}}{If \code{na.translate = TRUE}, what aesthetic value should the 41 | missing values be displayed as? Does not apply to position scales 42 | where \code{NA} is always placed at the far right.} 43 | \item{\code{aesthetics}}{The names of the aesthetics that this scale works with.} 44 | \item{\code{scale_name}}{The name of the scale that should be used for error messages 45 | associated with this scale.} 46 | \item{\code{name}}{The name of the scale. Used as the axis or legend title. If 47 | \code{waiver()}, the default, the name of the scale is taken from the first 48 | mapping used for that aesthetic. If \code{NULL}, the legend title will be 49 | omitted.} 50 | \item{\code{labels}}{One of: 51 | \itemize{ 52 | \item \code{NULL} for no labels 53 | \item \code{waiver()} for the default labels computed by the 54 | transformation object 55 | \item A character vector giving labels (must be same length as \code{breaks}) 56 | \item An expression vector (must be the same length as breaks). See ?plotmath for details. 57 | \item A function that takes the breaks as input and returns labels 58 | as output. Also accepts rlang \link[rlang:as_function]{lambda} function 59 | notation. 60 | }} 61 | \item{\code{super}}{The super class to use for the constructed scale} 62 | }} 63 | } 64 | \description{ 65 | See \code{\link{calc_shape_pal}()} for details. 66 | } 67 | \seealso{ 68 | \code{\link{theme_calc}()} for examples. 69 | 70 | Other shapes calc: 71 | \code{\link{calc_shape_pal}()} 72 | } 73 | \concept{shapes calc} 74 | -------------------------------------------------------------------------------- /man/scale_shape_circlefill.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/shapes.R 3 | \name{scale_shape_circlefill} 4 | \alias{scale_shape_circlefill} 5 | \title{Filled Circle Shape palette (discrete)} 6 | \usage{ 7 | scale_shape_circlefill(...) 8 | } 9 | \arguments{ 10 | \item{...}{ 11 | Arguments passed on to \code{\link[ggplot2:discrete_scale]{discrete_scale}} 12 | \describe{ 13 | \item{\code{palette}}{A palette function that when called with a single integer 14 | argument (the number of levels in the scale) returns the values that 15 | they should take (e.g., \code{\link[scales:hue_pal]{scales::hue_pal()}}).} 16 | \item{\code{breaks}}{One of: 17 | \itemize{ 18 | \item \code{NULL} for no breaks 19 | \item \code{waiver()} for the default breaks (the scale limits) 20 | \item A character vector of breaks 21 | \item A function that takes the limits as input and returns breaks 22 | as output. Also accepts rlang \link[rlang:as_function]{lambda} function 23 | notation. 24 | }} 25 | \item{\code{limits}}{One of: 26 | \itemize{ 27 | \item \code{NULL} to use the default scale values 28 | \item A character vector that defines possible values of the scale and their 29 | order 30 | \item A function that accepts the existing (automatic) values and returns 31 | new ones. Also accepts rlang \link[rlang:as_function]{lambda} function 32 | notation. 33 | }} 34 | \item{\code{drop}}{Should unused factor levels be omitted from the scale? 35 | The default, \code{TRUE}, uses the levels that appear in the data; 36 | \code{FALSE} uses all the levels in the factor.} 37 | \item{\code{na.translate}}{Unlike continuous scales, discrete scales can easily show 38 | missing values, and do so by default. If you want to remove missing values 39 | from a discrete scale, specify \code{na.translate = FALSE}.} 40 | \item{\code{na.value}}{If \code{na.translate = TRUE}, what aesthetic value should the 41 | missing values be displayed as? Does not apply to position scales 42 | where \code{NA} is always placed at the far right.} 43 | \item{\code{aesthetics}}{The names of the aesthetics that this scale works with.} 44 | \item{\code{scale_name}}{The name of the scale that should be used for error messages 45 | associated with this scale.} 46 | \item{\code{name}}{The name of the scale. Used as the axis or legend title. If 47 | \code{waiver()}, the default, the name of the scale is taken from the first 48 | mapping used for that aesthetic. If \code{NULL}, the legend title will be 49 | omitted.} 50 | \item{\code{labels}}{One of: 51 | \itemize{ 52 | \item \code{NULL} for no labels 53 | \item \code{waiver()} for the default labels computed by the 54 | transformation object 55 | \item A character vector giving labels (must be same length as \code{breaks}) 56 | \item An expression vector (must be the same length as breaks). See ?plotmath for details. 57 | \item A function that takes the breaks as input and returns labels 58 | as output. Also accepts rlang \link[rlang:as_function]{lambda} function 59 | notation. 60 | }} 61 | \item{\code{super}}{The super class to use for the constructed scale} 62 | }} 63 | } 64 | \description{ 65 | `r lifecycle::badge("deprecated")` 66 | } 67 | \seealso{ 68 | \code{\link{circlefill_shape_pal}()} for a description of the palette. 69 | 70 | Other shapes: 71 | \code{\link{circlefill_shape_pal}()}, 72 | \code{\link{cleveland_shape_pal}()}, 73 | \code{\link{scale_shape_cleveland}()}, 74 | \code{\link{scale_shape_tremmel}()}, 75 | \code{\link{tremmel_shape_pal}()} 76 | } 77 | \concept{shapes} 78 | -------------------------------------------------------------------------------- /man/scale_shape_few.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/few.R 3 | \name{scale_shape_few} 4 | \alias{scale_shape_few} 5 | \title{Scales for shapes from "Show Me the Numbers"} 6 | \usage{ 7 | scale_shape_few(...) 8 | } 9 | \arguments{ 10 | \item{...}{Common \code{\link[ggplot2]{discrete_scale}()} parameters.} 11 | } 12 | \description{ 13 | \code{scale_shape_few()} maps discrete variables to up to five easily 14 | discernible shapes. It is based on the shape palette suggested in 15 | Few (2012). 16 | } 17 | \references{ 18 | Few, S. (2012) 19 | \emph{Show Me the Numbers: Designing Tables and Graphs to Enlighten}, 20 | Analytics Press, p. 208. 21 | } 22 | \seealso{ 23 | \code{\link{scale_shape_few}()} for the shape palette that this 24 | scale uses. 25 | } 26 | -------------------------------------------------------------------------------- /man/scale_shape_stata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stata.R 3 | \name{scale_shape_stata} 4 | \alias{scale_shape_stata} 5 | \title{Stata shape scale} 6 | \usage{ 7 | scale_shape_stata(...) 8 | } 9 | \arguments{ 10 | \item{...}{ 11 | Arguments passed on to \code{\link[ggplot2:discrete_scale]{discrete_scale}} 12 | \describe{ 13 | \item{\code{palette}}{A palette function that when called with a single integer 14 | argument (the number of levels in the scale) returns the values that 15 | they should take (e.g., \code{\link[scales:hue_pal]{scales::hue_pal()}}).} 16 | \item{\code{breaks}}{One of: 17 | \itemize{ 18 | \item \code{NULL} for no breaks 19 | \item \code{waiver()} for the default breaks (the scale limits) 20 | \item A character vector of breaks 21 | \item A function that takes the limits as input and returns breaks 22 | as output. Also accepts rlang \link[rlang:as_function]{lambda} function 23 | notation. 24 | }} 25 | \item{\code{limits}}{One of: 26 | \itemize{ 27 | \item \code{NULL} to use the default scale values 28 | \item A character vector that defines possible values of the scale and their 29 | order 30 | \item A function that accepts the existing (automatic) values and returns 31 | new ones. Also accepts rlang \link[rlang:as_function]{lambda} function 32 | notation. 33 | }} 34 | \item{\code{drop}}{Should unused factor levels be omitted from the scale? 35 | The default, \code{TRUE}, uses the levels that appear in the data; 36 | \code{FALSE} uses all the levels in the factor.} 37 | \item{\code{na.translate}}{Unlike continuous scales, discrete scales can easily show 38 | missing values, and do so by default. If you want to remove missing values 39 | from a discrete scale, specify \code{na.translate = FALSE}.} 40 | \item{\code{na.value}}{If \code{na.translate = TRUE}, what aesthetic value should the 41 | missing values be displayed as? Does not apply to position scales 42 | where \code{NA} is always placed at the far right.} 43 | \item{\code{aesthetics}}{The names of the aesthetics that this scale works with.} 44 | \item{\code{scale_name}}{The name of the scale that should be used for error messages 45 | associated with this scale.} 46 | \item{\code{name}}{The name of the scale. Used as the axis or legend title. If 47 | \code{waiver()}, the default, the name of the scale is taken from the first 48 | mapping used for that aesthetic. If \code{NULL}, the legend title will be 49 | omitted.} 50 | \item{\code{labels}}{One of: 51 | \itemize{ 52 | \item \code{NULL} for no labels 53 | \item \code{waiver()} for the default labels computed by the 54 | transformation object 55 | \item A character vector giving labels (must be same length as \code{breaks}) 56 | \item An expression vector (must be the same length as breaks). See ?plotmath for details. 57 | \item A function that takes the breaks as input and returns labels 58 | as output. Also accepts rlang \link[rlang:as_function]{lambda} function 59 | notation. 60 | }} 61 | \item{\code{super}}{The super class to use for the constructed scale} 62 | }} 63 | } 64 | \description{ 65 | See \code{\link{stata_shape_pal}()} for details. 66 | } 67 | \examples{ 68 | \dontrun{ 69 | library("ggplot2") 70 | 71 | p <- ggplot(mtcars) + 72 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 73 | facet_wrap(~am) 74 | p + theme_stata() + scale_shape_stata() 75 | } 76 | } 77 | \concept{shape stata} 78 | -------------------------------------------------------------------------------- /man/scale_shape_tableau.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tableau.R 3 | \name{scale_shape_tableau} 4 | \alias{scale_shape_tableau} 5 | \title{Tableau shape scales} 6 | \usage{ 7 | scale_shape_tableau(palette = "default", ...) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette name.} 11 | 12 | \item{...}{ 13 | Arguments passed on to \code{\link[ggplot2:discrete_scale]{discrete_scale}} 14 | \describe{ 15 | \item{\code{palette}}{A palette function that when called with a single integer 16 | argument (the number of levels in the scale) returns the values that 17 | they should take (e.g., \code{\link[scales:hue_pal]{scales::hue_pal()}}).} 18 | \item{\code{breaks}}{One of: 19 | \itemize{ 20 | \item \code{NULL} for no breaks 21 | \item \code{waiver()} for the default breaks (the scale limits) 22 | \item A character vector of breaks 23 | \item A function that takes the limits as input and returns breaks 24 | as output. Also accepts rlang \link[rlang:as_function]{lambda} function 25 | notation. 26 | }} 27 | \item{\code{limits}}{One of: 28 | \itemize{ 29 | \item \code{NULL} to use the default scale values 30 | \item A character vector that defines possible values of the scale and their 31 | order 32 | \item A function that accepts the existing (automatic) values and returns 33 | new ones. Also accepts rlang \link[rlang:as_function]{lambda} function 34 | notation. 35 | }} 36 | \item{\code{drop}}{Should unused factor levels be omitted from the scale? 37 | The default, \code{TRUE}, uses the levels that appear in the data; 38 | \code{FALSE} uses all the levels in the factor.} 39 | \item{\code{na.translate}}{Unlike continuous scales, discrete scales can easily show 40 | missing values, and do so by default. If you want to remove missing values 41 | from a discrete scale, specify \code{na.translate = FALSE}.} 42 | \item{\code{na.value}}{If \code{na.translate = TRUE}, what aesthetic value should the 43 | missing values be displayed as? Does not apply to position scales 44 | where \code{NA} is always placed at the far right.} 45 | \item{\code{aesthetics}}{The names of the aesthetics that this scale works with.} 46 | \item{\code{scale_name}}{The name of the scale that should be used for error messages 47 | associated with this scale.} 48 | \item{\code{name}}{The name of the scale. Used as the axis or legend title. If 49 | \code{waiver()}, the default, the name of the scale is taken from the first 50 | mapping used for that aesthetic. If \code{NULL}, the legend title will be 51 | omitted.} 52 | \item{\code{labels}}{One of: 53 | \itemize{ 54 | \item \code{NULL} for no labels 55 | \item \code{waiver()} for the default labels computed by the 56 | transformation object 57 | \item A character vector giving labels (must be same length as \code{breaks}) 58 | \item An expression vector (must be the same length as breaks). See ?plotmath for details. 59 | \item A function that takes the breaks as input and returns labels 60 | as output. Also accepts rlang \link[rlang:as_function]{lambda} function 61 | notation. 62 | }} 63 | \item{\code{super}}{The super class to use for the constructed scale} 64 | }} 65 | } 66 | \description{ 67 | See \code{\link{tableau_shape_pal}()} for details. 68 | } 69 | \examples{ 70 | \dontrun{ 71 | library("ggplot2") 72 | 73 | p <- ggplot(mtcars) + 74 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 75 | facet_wrap(~am) 76 | p + scale_shape_tableau() 77 | } 78 | } 79 | \seealso{ 80 | Other shape tableau: 81 | \code{\link{tableau_shape_pal}()} 82 | } 83 | \concept{shape tableau} 84 | -------------------------------------------------------------------------------- /man/show_linetypes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/show.R 3 | \name{show_linetypes} 4 | \alias{show_linetypes} 5 | \title{Show linetypes} 6 | \usage{ 7 | show_linetypes(linetypes, labels = TRUE) 8 | } 9 | \arguments{ 10 | \item{linetypes}{A character vector of linetypes. See 11 | \code{\link{par}()}.} 12 | 13 | \item{labels}{Label each line with its linetype (lty) value.} 14 | } 15 | \value{ 16 | This function called for the side effect of creating a plot. 17 | It returns \code{linetypes}. 18 | } 19 | \description{ 20 | A quick and dirty way to show linetypes. 21 | } 22 | \examples{ 23 | library("scales") 24 | 25 | show_linetypes(linetype_pal()(3)) 26 | show_linetypes(linetype_pal()(3), labels = TRUE) 27 | } 28 | \seealso{ 29 | \code{\link[scales]{show_col}()}, \code{\link{show_linetypes}()} 30 | } 31 | -------------------------------------------------------------------------------- /man/show_shapes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/show.R 3 | \name{show_shapes} 4 | \alias{show_shapes} 5 | \title{Show shapes} 6 | \usage{ 7 | show_shapes(shapes, labels = TRUE) 8 | } 9 | \arguments{ 10 | \item{shapes}{A numeric or character vector of shapes. See 11 | \code{\link[graphics]{par}()}.} 12 | 13 | \item{labels}{Include the plotting character value of the symbol.} 14 | } 15 | \value{ 16 | This function called for the side effect of creating a plot. 17 | It returns \code{shapes}. 18 | } 19 | \description{ 20 | A quick and dirty way to show shapes. 21 | } 22 | \examples{ 23 | library("scales") 24 | 25 | show_shapes(shape_pal()(5)) 26 | show_shapes(shape_pal()(3), labels = TRUE) 27 | } 28 | \seealso{ 29 | \code{\link[scales]{show_col}()}, \code{\link{show_linetypes}()} 30 | } 31 | -------------------------------------------------------------------------------- /man/smart_digits.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/scales.R 3 | \name{smart_digits} 4 | \alias{smart_digits} 5 | \alias{smart_digits_format} 6 | \title{Format numbers with automatic number of digits} 7 | \usage{ 8 | smart_digits(x, ...) 9 | 10 | smart_digits_format(x, ...) 11 | } 12 | \arguments{ 13 | \item{x}{A numeric vector to format} 14 | 15 | \item{...}{Parameters passed to \code{\link{format}()}} 16 | } 17 | \value{ 18 | A character vector. 19 | \code{smart_digits_format()} returns a function with a single argument 20 | \code{x}, a numeric vector, that returns a character vector. 21 | } 22 | \description{ 23 | Format numbers with automatic number of digits 24 | } 25 | \references{ 26 | Josh O'Brien, 27 | \url{https://stackoverflow.com/questions/23169938/select-accuracy-to-display-additional-axis-breaks/23171858#23171858}. 28 | } 29 | \author{ 30 | Josh O'Brien, Baptise Auguie, Jeffrey B. Arnold 31 | } 32 | -------------------------------------------------------------------------------- /man/solarized_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/solarized.R 3 | \name{solarized_pal} 4 | \alias{solarized_pal} 5 | \title{Solarized color palette (discrete)} 6 | \usage{ 7 | solarized_pal(accent = "blue") 8 | } 9 | \arguments{ 10 | \item{accent}{\code{character} Starting color.} 11 | } 12 | \description{ 13 | Qualitative color palate based on the Ethan Schoonover's Solarized 14 | palette, \url{https://ethanschoonover.com/solarized/}. This palette supports 15 | up to seven values. 16 | } 17 | \note{ 18 | For a given starting color and number of colors in the palette, 19 | the other colors are the combination of colors that maximizes the 20 | total Euclidean distance between colors in L*a*b space. 21 | } 22 | \examples{ 23 | library("scales") 24 | 25 | show_col(solarized_pal()(2)) 26 | show_col(solarized_pal()(3)) 27 | show_col(solarized_pal("red")(4)) 28 | } 29 | \seealso{ 30 | Other solarized colour: 31 | \code{\link{scale_fill_solarized}()} 32 | } 33 | \concept{solarized colour} 34 | -------------------------------------------------------------------------------- /man/solarized_rebase.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/solarized.R 3 | \name{solarized_rebase} 4 | \alias{solarized_rebase} 5 | \title{Base colors for Solarized light and dark themes} 6 | \usage{ 7 | solarized_rebase(light = TRUE) 8 | } 9 | \arguments{ 10 | \item{light}{\code{logical} Light theme? 11 | 12 | Creates the base colors for a light or dark solarized theme. See 13 | \url{https://ethanschoonover.com/solarized/}. This function is a port 14 | of the CSS style example.} 15 | } 16 | \description{ 17 | Base colors for Solarized light and dark themes 18 | } 19 | \keyword{internal} 20 | -------------------------------------------------------------------------------- /man/stata_linetype_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stata.R 3 | \name{stata_linetype_pal} 4 | \alias{stata_linetype_pal} 5 | \title{Stata linetype palette (discrete)} 6 | \usage{ 7 | stata_linetype_pal() 8 | } 9 | \description{ 10 | Linetype palette based on the linepattern scheme in Stata. 11 | This palette supports up to 15 values. 12 | } 13 | \seealso{ 14 | \code{\link{scale_linetype_stata}()} 15 | 16 | Other linetype stata: 17 | \code{\link{scale_linetype_stata}()} 18 | } 19 | \concept{linetype stata} 20 | -------------------------------------------------------------------------------- /man/stata_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stata.R 3 | \name{stata_pal} 4 | \alias{stata_pal} 5 | \title{Stata color palettes (discrete)} 6 | \usage{ 7 | stata_pal(scheme = "s2color") 8 | } 9 | \arguments{ 10 | \item{scheme}{\code{character}. One of \code{"s2color"}, 11 | \code{"s1rcolor"}, \code{"s1color"}, or \code{"mono"}.} 12 | } 13 | \description{ 14 | Stata color palettes. See Stata documentation for a description of 15 | the schemes, \url{https://www.stata.com/help.cgi?schemes}. 16 | } 17 | \details{ 18 | All these palettes support up to 15 values. 19 | } 20 | \examples{ 21 | library("scales") 22 | 23 | show_col(stata_pal("s2color")(15)) 24 | show_col(stata_pal("s1rcolor")(15)) 25 | show_col(stata_pal("s1color")(15)) 26 | show_col(stata_pal("mono")(15)) 27 | } 28 | \concept{stata colour} 29 | -------------------------------------------------------------------------------- /man/stata_shape_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stata.R 3 | \name{stata_shape_pal} 4 | \alias{stata_shape_pal} 5 | \title{Stata shape palette (discrete)} 6 | \usage{ 7 | stata_shape_pal() 8 | } 9 | \description{ 10 | Shape palette based on the symbol palette in Stata used in scheme s2mono. 11 | This palette supports up to 10 values. 12 | } 13 | \seealso{ 14 | See \code{\link{scale_shape_stata}()} for examples. 15 | } 16 | \concept{shapes stata} 17 | -------------------------------------------------------------------------------- /man/tableau_color_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tableau.R 3 | \name{tableau_color_pal} 4 | \alias{tableau_color_pal} 5 | \title{Tableau Color Palettes (discrete)} 6 | \usage{ 7 | tableau_color_pal( 8 | palette = "Tableau 10", 9 | type = c("regular", "ordered-sequential", "ordered-diverging"), 10 | direction = 1 11 | ) 12 | } 13 | \arguments{ 14 | \item{palette}{Palette name. See Details for available palettes.} 15 | 16 | \item{type}{Type of palette. One of \code{"regular"}, \code{"ordered-diverging"}, or \code{"ordered-sequential"}.} 17 | 18 | \item{direction}{If 1, the default, then use the original order of 19 | colors. If -1, then reverse the order.} 20 | } 21 | \description{ 22 | Color palettes used in \href{https://www.tableau.com/}{Tableau}. 23 | } 24 | \details{ 25 | Tableau provides three types of color palettes: 26 | \code{"regular"} (discrete, qualitative categories), 27 | \code{"ordered-sequential"}, and \code{"ordered-diverging"}. 28 | 29 | \describe{ 30 | \item{\code{"regular"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["regular"]]))}} 31 | \item{\code{"ordered-diverging"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["ordered-diverging"]]))}} 32 | \item{\code{"ordered-sequential"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["ordered-sequential"]]))}} 33 | } 34 | } 35 | \examples{ 36 | library("scales") 37 | 38 | palettes <- ggthemes_data[["tableau"]][["color-palettes"]][["regular"]] 39 | for (palname in names(palettes)) { 40 | pal <- tableau_color_pal(palname) 41 | max_n <- attr(pal, "max_n") 42 | show_col(pal(max_n)) 43 | title(main = palname) 44 | } 45 | } 46 | \references{ 47 | \url{http://vis.stanford.edu/color-names/analyzer/} 48 | 49 | Maureen Stone, 'Designing Colors for Data' (slides), at the 50 | International Symposium on Computational Aesthetics in Graphics, 51 | Visualization, and Imaging, Banff, AB, Canada, June 22, 2007. 52 | 53 | Heer, Jeffrey and Maureen Stone, 2012 'Color Naming Models for 54 | Color Selection, Image Editing and Palette Design', ACM Human 55 | Factors in Computing Systems (CHI) 56 | \url{http://vis.stanford.edu/files/2012-ColorNameModels-CHI.pdf}. 57 | } 58 | \seealso{ 59 | Other colour tableau: 60 | \code{\link{scale_colour_gradient2_tableau}()}, 61 | \code{\link{scale_colour_gradient_tableau}()}, 62 | \code{\link{scale_colour_tableau}()}, 63 | \code{\link{tableau_gradient_pal}()} 64 | } 65 | \concept{colour tableau} 66 | -------------------------------------------------------------------------------- /man/tableau_gradient_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tableau.R 3 | \name{tableau_gradient_pal} 4 | \alias{tableau_gradient_pal} 5 | \alias{tableau_seq_gradient_pal} 6 | \alias{tableau_div_gradient_pal} 7 | \title{Tableau colour gradient palettes (continuous)} 8 | \usage{ 9 | tableau_gradient_pal(palette = "Blue", type = "ordered-sequential") 10 | 11 | tableau_seq_gradient_pal(palette = "Blue", ...) 12 | 13 | tableau_div_gradient_pal(palette = "Orange-Blue Diverging", ...) 14 | } 15 | \arguments{ 16 | \item{palette}{Palette name. 17 | \describe{ 18 | \item{\code{"ordered-sequential"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["ordered-sequential"]]))}} 19 | \item{\code{"ordered-diverging"}}{\Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$tableau[["color-palettes"]][["ordered-diverging"]]))}} 20 | }} 21 | 22 | \item{type}{Palette type, either \code{"ordered-sequential"} or 23 | \code{"ordered-diverging"}.} 24 | 25 | \item{...}{Arguments passed to \code{tableau_gradient_pal}.} 26 | } 27 | \description{ 28 | Gradient color palettes using the diverging and sequential continous color 29 | palettes in Tableau. See \funclink{tableau_color_pal} for discrete color 30 | palettes. 31 | } 32 | \examples{ 33 | library("scales") 34 | 35 | x <- seq(0, 1, length = 25) 36 | r <- sqrt(outer(x^2, x^2, "+")) 37 | palettes <- 38 | ggthemes_data[["tableau"]][["color-palettes"]][["ordered-sequential"]] 39 | for (palname in names(palettes)) { 40 | col <- tableau_seq_gradient_pal(palname)(seq(0, 1, length = 12)) 41 | image(r, col = col) 42 | title(main = palname) 43 | } 44 | } 45 | \seealso{ 46 | Other colour tableau: 47 | \code{\link{scale_colour_gradient2_tableau}()}, 48 | \code{\link{scale_colour_gradient_tableau}()}, 49 | \code{\link{scale_colour_tableau}()}, 50 | \code{\link{tableau_color_pal}()} 51 | } 52 | \concept{colour tableau} 53 | -------------------------------------------------------------------------------- /man/tableau_shape_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tableau.R 3 | \name{tableau_shape_pal} 4 | \alias{tableau_shape_pal} 5 | \title{Tableau Shape Palettes (discrete)} 6 | \usage{ 7 | tableau_shape_pal(palette = c("default", "filled", "proportions")) 8 | } 9 | \arguments{ 10 | \item{palette}{Palette name.} 11 | } 12 | \description{ 13 | Shape palettes used by 14 | \href{https://www.tableau.com/}{Tableau}. 15 | } 16 | \details{ 17 | Not all shape palettes in Tableau are supported. Additionally, these 18 | palettes are not exact, and use the best unicode character for the shape 19 | palette. 20 | 21 | Since these palettes use unicode characters, their look may depend on the 22 | font being used, and not all characters may be available. 23 | 24 | Shape palettes in Tableau are used to expose images for use a markers in 25 | charts, and thus are sometimes groupings of closely related symbols. 26 | } 27 | \examples{ 28 | \dontrun{ 29 | # need to set a font containing these values 30 | show_shapes(tableau_shape_pal()(5)) 31 | } 32 | } 33 | \seealso{ 34 | Other shape tableau: 35 | \code{\link{scale_shape_tableau}()} 36 | } 37 | \concept{shape tableau} 38 | -------------------------------------------------------------------------------- /man/theme_base.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/base.R 3 | \name{theme_base} 4 | \alias{theme_base} 5 | \title{Theme Base} 6 | \usage{ 7 | theme_base(base_size = 16, base_family = "") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \description{ 15 | Theme similar to the default settings of the \sQuote{base} R graphics. 16 | } 17 | \examples{ 18 | library("ggplot2") 19 | 20 | p <- ggplot(mtcars) + 21 | geom_point(aes( 22 | x = wt, y = mpg, 23 | colour = factor(gear) 24 | )) + 25 | facet_wrap(~am) 26 | p + theme_base() 27 | # Change values of par 28 | par(fg = "blue", bg = "gray", col.lab = "red", font.lab = 3) 29 | p + theme_base() 30 | } 31 | \seealso{ 32 | Other themes: 33 | \code{\link{theme_clean}()}, 34 | \code{\link{theme_foundation}()}, 35 | \code{\link{theme_igray}()}, 36 | \code{\link{theme_par}()}, 37 | \code{\link{theme_solid}()} 38 | } 39 | \concept{themes} 40 | -------------------------------------------------------------------------------- /man/theme_calc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/calc.R 3 | \name{theme_calc} 4 | \alias{theme_calc} 5 | \title{Theme Calc} 6 | \usage{ 7 | theme_calc(base_size = 10, base_family = "sans") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \description{ 15 | Theme similar to the default settings of LibreOffice Calc charts. 16 | } 17 | \examples{ 18 | library("ggplot2") 19 | 20 | ggplot(mtcars) + 21 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 22 | facet_wrap(~am) + 23 | theme_calc() + 24 | scale_color_calc() 25 | \dontrun{ 26 | ggplot(mtcars) + 27 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 28 | facet_wrap(~am) + 29 | theme_calc() + 30 | scale_shape_calc() 31 | } 32 | } 33 | \concept{themes calc} 34 | -------------------------------------------------------------------------------- /man/theme_clean.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/clean.R 3 | \name{theme_clean} 4 | \alias{theme_clean} 5 | \title{Clean ggplot theme} 6 | \usage{ 7 | theme_clean(base_size = 12, base_family = "sans") 8 | } 9 | \arguments{ 10 | \item{base_size}{Base font size.} 11 | 12 | \item{base_family}{Base font family.} 13 | } 14 | \description{ 15 | Clean ggplot theme with no panel background, black axis lines 16 | and grey fill colour for chart elements. 17 | } 18 | \examples{ 19 | library("ggplot2") 20 | p <- ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(gear))) + 21 | geom_point() + 22 | facet_wrap(~am) + 23 | geom_smooth(method = "lm", se = FALSE) + 24 | theme_clean() 25 | p 26 | } 27 | \seealso{ 28 | Other themes: 29 | \code{\link{theme_base}()}, 30 | \code{\link{theme_foundation}()}, 31 | \code{\link{theme_igray}()}, 32 | \code{\link{theme_par}()}, 33 | \code{\link{theme_solid}()} 34 | } 35 | \author{ 36 | Konrad Zdeb \email{name.surname@me.com} 37 | } 38 | \concept{themes} 39 | -------------------------------------------------------------------------------- /man/theme_economist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/economist.R 3 | \name{theme_economist} 4 | \alias{theme_economist} 5 | \alias{theme_economist_white} 6 | \title{ggplot color theme based on the Economist} 7 | \usage{ 8 | theme_economist( 9 | base_size = 10, 10 | base_family = "sans", 11 | horizontal = TRUE, 12 | dkpanel = FALSE 13 | ) 14 | 15 | theme_economist_white( 16 | base_size = 11, 17 | base_family = "sans", 18 | gray_bg = TRUE, 19 | horizontal = TRUE 20 | ) 21 | } 22 | \arguments{ 23 | \item{base_size}{base font size, given in pts.} 24 | 25 | \item{base_family}{base font family} 26 | 27 | \item{horizontal}{\code{logical} Horizontal axis lines?} 28 | 29 | \item{dkpanel}{\code{logical} Darker background for panel region?} 30 | 31 | \item{gray_bg}{\code{logical} If \code{TRUE}, use gray background, else 32 | use white 33 | background.} 34 | } 35 | \value{ 36 | An object of class \code{\link[ggplot2]{theme}()}. 37 | } 38 | \description{ 39 | A theme that approximates the style of \emph{The Economist}. 40 | } 41 | \details{ 42 | \code{theme_economist} implements the standard bluish-gray 43 | background theme in the print \emph{The Economist} and 44 | \href{https://www.economist.com/}{economist.com}. 45 | 46 | \code{theme_economist_white} implements a variant with a while 47 | panel and light gray (or white) background often used by \emph{The Economist} 48 | blog \href{https://www.economist.com/blogs/graphicdetail}{Graphic Detail}. 49 | 50 | Use \code{\link{scale_color_economist}()} with this theme. 51 | The x axis should be displayed on the right hand side. 52 | 53 | \emph{The Economist} uses "ITC Officina Sans" as its font for graphs. If 54 | you have access to this font, you can use it with the 55 | \pkg{extrafont} package. "Verdana" is a good substitute. 56 | } 57 | \examples{ 58 | library("ggplot2") 59 | 60 | p <- ggplot(mtcars) + 61 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 62 | facet_wrap(~am) + 63 | # Economist puts x-axis labels on the right-hand side 64 | scale_y_continuous(position = "right") 65 | 66 | ## Standard 67 | p + theme_economist() + 68 | scale_colour_economist() 69 | 70 | # Change axis lines to vertical 71 | p + theme_economist(horizontal = FALSE) + 72 | scale_colour_economist() + 73 | coord_flip() 74 | 75 | ## White panel/light gray background 76 | p + theme_economist_white() + 77 | scale_colour_economist() 78 | 79 | ## All white variant 80 | p + theme_economist_white(gray_bg = FALSE) + 81 | scale_colour_economist() 82 | 83 | \dontrun{ 84 | 85 | ## The Economist uses ITC Officina Sans 86 | library("extrafont") 87 | p + theme_economist(base_family="ITC Officina Sans") + 88 | scale_colour_economist() 89 | 90 | ## Verdana is a widely available substitute 91 | p + theme_economist(base_family="Verdana") + 92 | scale_colour_economist() 93 | 94 | } 95 | } 96 | \references{ 97 | \itemize{ 98 | \item \href{https://www.economist.com/}{The Economist} 99 | \item \href{https://spiekermann.com/en/itc-officina-display/}{Spiekerblog, "ITC Officina Display", January 1, 2007.} 100 | } 101 | } 102 | \concept{themes economist} 103 | -------------------------------------------------------------------------------- /man/theme_excel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/excel.R 3 | \name{theme_excel} 4 | \alias{theme_excel} 5 | \title{ggplot theme based on old Excel plots} 6 | \usage{ 7 | theme_excel(base_size = 12, base_family = "", horizontal = TRUE) 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | 14 | \item{horizontal}{\code{logical}. Horizontal axis lines?} 15 | } 16 | \value{ 17 | An object of class \code{\link[ggplot2]{theme}()}. 18 | } 19 | \description{ 20 | Theme to replicate the ugly monstrosity that was the old 21 | gray-background Excel chart. Please never use this. 22 | This theme should be combined with the \code{\link{scale_colour_excel}()} 23 | color scale. 24 | } 25 | \examples{ 26 | library("ggplot2") 27 | 28 | # Line and scatter plot colors 29 | p <- ggplot(mtcars) + 30 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 31 | facet_wrap(~am) 32 | p + theme_excel() + scale_colour_excel() 33 | 34 | # Bar plot (area/fill) colors 35 | ggplot(mpg, aes(x = class, fill = drv)) + 36 | geom_bar() + 37 | scale_fill_excel() + 38 | theme_excel() 39 | } 40 | \seealso{ 41 | Other themes excel: 42 | \code{\link{theme_excel_new}()} 43 | } 44 | \concept{themes excel} 45 | -------------------------------------------------------------------------------- /man/theme_excel_new.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/excel.R 3 | \name{theme_excel_new} 4 | \alias{theme_excel_new} 5 | \title{ggplot theme similar to current Excel plot defaults} 6 | \usage{ 7 | theme_excel_new(base_size = 9, base_family = "sans") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \value{ 15 | An object of class \code{\link[ggplot2]{theme}()}. 16 | } 17 | \description{ 18 | Theme for ggplot2 that is similar to the default style of charts in 19 | current versions of Microsoft Excel. 20 | } 21 | \examples{ 22 | library("ggplot2") 23 | 24 | p <- ggplot(mtcars) + 25 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 26 | facet_wrap(~am) 27 | p + theme_excel_new() + scale_colour_excel_new() 28 | } 29 | \seealso{ 30 | Other themes excel: 31 | \code{\link{theme_excel}()} 32 | } 33 | \concept{themes excel} 34 | -------------------------------------------------------------------------------- /man/theme_few.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/few.R 3 | \name{theme_few} 4 | \alias{theme_few} 5 | \title{Theme based on Few's "Practical Rules for Using Color in Charts"} 6 | \usage{ 7 | theme_few(base_size = 12, base_family = "") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \description{ 15 | Theme based on the rules and examples from Stephen Few's 16 | \emph{Show Me the Numbers} and "Practical Rules for Using Color in Charts". 17 | } 18 | \examples{ 19 | library("ggplot2") 20 | 21 | p <- ggplot(mtcars) + 22 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 23 | facet_wrap(~am) 24 | p + theme_few() + scale_colour_few() 25 | p + theme_few() + scale_colour_few("Light") 26 | p + theme_few() + scale_colour_few("Dark") 27 | 28 | ggplot(mtcars) + 29 | geom_point(aes(x = wt, y = mpg, shape = factor(gear))) + 30 | theme_few() + 31 | scale_shape_few() 32 | } 33 | \references{ 34 | Few, S. (2012) \emph{Show Me the Numbers: Designing Tables and Graphs to Enlighten}. 35 | 2nd edition. Analytics Press. 36 | 37 | Stephen Few, "Practical Rules for Using Color in Charts", 38 | \url{https://www.perceptualedge.com/articles/visual_business_intelligence/rules_for_using_color.pdf}. 39 | } 40 | \concept{themes few} 41 | -------------------------------------------------------------------------------- /man/theme_fivethirtyeight.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fivethirtyeight.R 3 | \name{theme_fivethirtyeight} 4 | \alias{theme_fivethirtyeight} 5 | \title{Theme inspired by FiveThirtyEight plots} 6 | \usage{ 7 | theme_fivethirtyeight(base_size = 12, base_family = "sans") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \description{ 15 | Theme inspired by the plots from FiveThirtyEight.com. 16 | } 17 | \examples{ 18 | library("ggplot2") 19 | p <- ggplot(mtcars, aes(x = wt, y = mpg, colour = factor(gear))) + 20 | geom_point() + 21 | facet_wrap(~am) + 22 | geom_smooth(method = "lm", se = FALSE) + 23 | scale_color_fivethirtyeight() + 24 | theme_fivethirtyeight() 25 | p 26 | } 27 | \concept{themes fivethirtyeight} 28 | -------------------------------------------------------------------------------- /man/theme_foundation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/theme-foundation.R 3 | \name{theme_foundation} 4 | \alias{theme_foundation} 5 | \title{Foundation Theme} 6 | \usage{ 7 | theme_foundation(base_size = 12, base_family = "") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \description{ 15 | This theme is designed to be a foundation from which to build new 16 | themes, and not meant to be used directly. \code{theme_foundation()} 17 | is a complete theme with only minimal number of elements defined. 18 | It is easier to create new themes by extending this one rather 19 | than \code{\link[ggplot2]{theme_gray}()} or \code{\link[ggplot2]{theme_bw}()}, 20 | because those themes define elements deep in the hierarchy. 21 | } 22 | \details{ 23 | This theme takes \code{\link[ggplot2]{theme_gray}()} and sets all 24 | \code{colour} and \code{fill} values to \code{NULL}, except for the top-level 25 | elements (\code{line}, \code{rect}, and \code{title}), which have 26 | \code{colour = "black"}, and \code{fill = "white"}. This leaves the spacing 27 | and-non colour defaults of the default \pkg{ggplot2} themes in place. 28 | } 29 | \seealso{ 30 | Other themes: 31 | \code{\link{theme_base}()}, 32 | \code{\link{theme_clean}()}, 33 | \code{\link{theme_igray}()}, 34 | \code{\link{theme_par}()}, 35 | \code{\link{theme_solid}()} 36 | } 37 | \concept{themes} 38 | -------------------------------------------------------------------------------- /man/theme_gdocs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gdocs.R 3 | \name{theme_gdocs} 4 | \alias{theme_gdocs} 5 | \title{Theme with Google Docs Chart defaults} 6 | \usage{ 7 | theme_gdocs(base_size = 12, base_family = "sans") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \description{ 15 | Theme similar to the default look of charts in Google Docs. 16 | } 17 | \examples{ 18 | library("ggplot2") 19 | 20 | p <- ggplot(mtcars) + 21 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 22 | facet_wrap(~am) 23 | p + theme_gdocs() + scale_color_gdocs() 24 | } 25 | \concept{themes gdocs} 26 | -------------------------------------------------------------------------------- /man/theme_hc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hc.R 3 | \name{theme_hc} 4 | \alias{theme_hc} 5 | \title{Highcharts Theme} 6 | \usage{ 7 | theme_hc( 8 | base_size = 12, 9 | base_family = "sans", 10 | style = c("default", "darkunica"), 11 | bgcolor = NULL 12 | ) 13 | } 14 | \arguments{ 15 | \item{base_size}{base font size, given in pts.} 16 | 17 | \item{base_family}{base font family} 18 | 19 | \item{style}{The Highcharts theme to use \code{'default'}, 20 | \code{'darkunica'}.} 21 | 22 | \item{bgcolor}{Deprecated} 23 | } 24 | \description{ 25 | Theme based on \href{https://www.highcharts.com/}{Highcharts} plots. 26 | } 27 | \examples{ 28 | library("ggplot2") 29 | 30 | p <- ggplot(mtcars) + 31 | geom_point(aes( 32 | x = wt, y = mpg, 33 | colour = factor(gear) 34 | )) + 35 | facet_wrap(~am) 36 | p + theme_hc() + scale_colour_hc() 37 | p + theme_hc(bgcolor = "darkunica") + 38 | scale_colour_hc("darkunica") 39 | 40 | dtemp <- data.frame( 41 | months = factor(rep(substr(month.name, 1, 3), 4), 42 | levels = substr(month.name, 1, 3) 43 | ), 44 | city = rep(c("Tokyo", "New York", "Berlin", "London"), 45 | each = 12 46 | ), 47 | temp = c( 48 | 7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 49 | 25.2, 26.5, 23.3, 18.3, 13.9, 9.6, 50 | -0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 51 | 24.8, 24.1, 20.1, 14.1, 8.6, 2.5, 52 | -0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 53 | 18.6, 17.9, 14.3, 9.0, 3.9, 1.0, 54 | 3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 55 | 17.0, 16.6, 14.2, 10.3, 6.6, 4.8 56 | ) 57 | ) 58 | 59 | ggplot(dtemp, aes(x = months, y = temp, group = city, color = city)) + 60 | geom_line() + 61 | geom_point(size = 1.1) + 62 | ggtitle("Monthly Average Temperature") + 63 | theme_hc() + 64 | scale_colour_hc() 65 | 66 | ggplot(dtemp, aes(x = months, y = temp, group = city, color = city)) + 67 | geom_line() + 68 | geom_point(size = 1.1) + 69 | ggtitle("Monthly Average Temperature") + 70 | theme_hc(bgcolor = "darkunica") + 71 | scale_fill_hc("darkunica") 72 | } 73 | \references{ 74 | \url{https://www.highcharts.com/demo/highcharts/line-chart} 75 | } 76 | \concept{themes hc} 77 | -------------------------------------------------------------------------------- /man/theme_igray.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/igray.R 3 | \name{theme_igray} 4 | \alias{theme_igray} 5 | \title{Inverse gray theme} 6 | \usage{ 7 | theme_igray(base_size = 12, base_family = "") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \description{ 15 | Theme with white panel and gray background. 16 | } 17 | \section{Details}{ 18 | 19 | 20 | This theme inverts the colors in the \code{\link[ggplot2]{theme_gray}()}, a 21 | white panel and a light gray area around it. This keeps a white 22 | background for the color scales like \code{\link[ggplot2]{theme_bw}()}. But 23 | by using a gray background, the plot is closer to the 24 | typographical color of the document, which is the motivation for 25 | using a gray panel in \code{\link[ggplot2]{theme_gray}()}. This is 26 | similar to the style of plots in Stata and Tableau. 27 | } 28 | 29 | \examples{ 30 | library("ggplot2") 31 | 32 | p <- ggplot(mtcars) + 33 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 34 | facet_wrap(~am) 35 | p + theme_igray() 36 | } 37 | \seealso{ 38 | \code{\link[ggplot2]{theme_gray}()}, 39 | \code{\link[ggplot2]{theme_bw}()} 40 | 41 | Other themes: 42 | \code{\link{theme_base}()}, 43 | \code{\link{theme_clean}()}, 44 | \code{\link{theme_foundation}()}, 45 | \code{\link{theme_par}()}, 46 | \code{\link{theme_solid}()} 47 | } 48 | \concept{themes} 49 | -------------------------------------------------------------------------------- /man/theme_map.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/theme-map.R 3 | \name{theme_map} 4 | \alias{theme_map} 5 | \title{Clean theme for maps} 6 | \usage{ 7 | theme_map(base_size = 9, base_family = "") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | } 14 | \description{ 15 | A clean theme that is good for displaying maps from 16 | \code{\link[ggplot2]{geom_map}()}. 17 | } 18 | \examples{ 19 | library("maps") 20 | library("ggplot2") 21 | 22 | us <- fortify(map_data("state"), region = "region") 23 | gg <- ggplot() + 24 | geom_map( 25 | data = us, map = us, 26 | aes(x = long, y = lat, map_id = region, group = group), 27 | fill = "white", color = "black", size = 0.25 28 | ) + 29 | coord_map("albers", lat0 = 39, lat1 = 45) + 30 | theme_map() 31 | gg 32 | } 33 | -------------------------------------------------------------------------------- /man/theme_pander.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pander.R 3 | \name{theme_pander} 4 | \alias{theme_pander} 5 | \title{A ggplot theme originated from the pander package} 6 | \usage{ 7 | theme_pander( 8 | base_size = 12, 9 | base_family = "sans", 10 | nomargin = TRUE, 11 | ff = NULL, 12 | fc = "black", 13 | fs = NULL, 14 | gM = TRUE, 15 | gm = TRUE, 16 | gc = "grey", 17 | gl = "dashed", 18 | boxes = FALSE, 19 | bc = "white", 20 | pc = "transparent", 21 | lp = "right", 22 | axis = 1 23 | ) 24 | } 25 | \arguments{ 26 | \item{base_size}{base font size, given in pts.} 27 | 28 | \item{base_family}{base font family} 29 | 30 | \item{nomargin}{suppress the white space around the plot (boolean)} 31 | 32 | \item{ff}{font family, like \code{sans}. Deprecated: use \code{base_family} instead.} 33 | 34 | \item{fc}{font color (name or hexa code)} 35 | 36 | \item{fs}{font size (integer). Deprecated: use \code{base_size} instead.} 37 | 38 | \item{gM}{major grid (boolean)} 39 | 40 | \item{gm}{minor grid (boolean)} 41 | 42 | \item{gc}{grid color (name or hexa code)} 43 | 44 | \item{gl}{grid line type (\code{lty})} 45 | 46 | \item{boxes}{to render a border around the plot or not} 47 | 48 | \item{bc}{background color (name or hexa code)} 49 | 50 | \item{pc}{panel background color (name or hexa code)} 51 | 52 | \item{lp}{legend position} 53 | 54 | \item{axis}{axis angle as defined in \code{par(les)}} 55 | } 56 | \description{ 57 | The \pkg{pander} ships with a default theme when the 'unify plots' option is 58 | enabled via \code{panderOptions}, which is now also available outside of \pkg{pander} internals, like \code{evals}, 59 | \code{eval.msgs} or \code{Pandoc.brew}. 60 | } 61 | \examples{ 62 | require("ggplot2") 63 | if (require("pander")) { 64 | p <- ggplot(mtcars, aes(x = mpg, y = wt)) + 65 | geom_point() 66 | p + theme_pander() 67 | 68 | panderOptions("graph.grid.color", "red") 69 | p + theme_pander() 70 | 71 | p <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + 72 | geom_point() 73 | p + theme_pander() + scale_color_pander() 74 | 75 | ggplot(mpg, aes(x = class, fill = drv)) + 76 | geom_bar() + 77 | scale_fill_pander() + 78 | theme_pander() 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /man/theme_par.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/base.R 3 | \name{theme_par} 4 | \alias{theme_par} 5 | \title{Theme which uses the current \sQuote{base} graphics parameter values 6 | from \code{\link[graphics]{par}()}. 7 | Not all \code{par()} parameters, are supported, and not all are relevant to 8 | \pkg{ggplot2} themes.} 9 | \usage{ 10 | theme_par(base_size = par()$ps, base_family = par()$family) 11 | } 12 | \arguments{ 13 | \item{base_size}{base font size, given in pts.} 14 | 15 | \item{base_family}{base font family} 16 | } 17 | \description{ 18 | Currently this theme uses the values of the parameters: 19 | \code{"code"}, "\code{"ps"}", \code{"code"} \code{"family"}, \code{"fg"}, 20 | \code{"bg"}, \code{"adj"}, \code{"font"}, \code{"cex.axis"}, 21 | \code{"cex.lab"}, \code{"cex.main"}, \code{"cex.sub"}, \code{"col.axis"}, 22 | \code{"col.lab"}, \code{"col.main"}, \code{"col.sub"}, \code{"font"}, 23 | \code{"font.axis"}, \code{"font.lab"}, \code{"font.main"}, 24 | \code{"font.sub"}, \code{"las"}, \code{"lend"}, 25 | \code{"lheight"}, \code{"lty"}, \code{"mar"}, \code{"ps"}, \code{"tcl"}, 26 | \code{"tck"}, \code{"xaxt"}, \code{"yaxt"}. 27 | } 28 | \details{ 29 | This theme does not translate the base graphics perfectly, so the graphs 30 | produced by it will not be identical to those produced by base graphics, 31 | most notably in the spacing of the margins. 32 | } 33 | \examples{ 34 | library("ggplot2") 35 | 36 | p <- ggplot(mtcars) + 37 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 38 | facet_wrap(~am) 39 | 40 | p + theme_par() 41 | 42 | # theme changes with respect to values of par 43 | par(font = 2, col.lab = "red", fg = "white", bg = "black") 44 | p + theme_par() 45 | } 46 | \seealso{ 47 | Other themes: 48 | \code{\link{theme_base}()}, 49 | \code{\link{theme_clean}()}, 50 | \code{\link{theme_foundation}()}, 51 | \code{\link{theme_igray}()}, 52 | \code{\link{theme_solid}()} 53 | } 54 | \concept{themes} 55 | -------------------------------------------------------------------------------- /man/theme_solarized.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/solarized.R 3 | \name{theme_solarized} 4 | \alias{theme_solarized} 5 | \alias{theme_solarized_2} 6 | \title{ggplot color themes based on the Solarized palette} 7 | \usage{ 8 | theme_solarized(base_size = 12, base_family = "", light = TRUE) 9 | 10 | theme_solarized_2(base_size = 12, base_family = "", light = TRUE) 11 | } 12 | \arguments{ 13 | \item{base_size}{base font size, given in pts.} 14 | 15 | \item{base_family}{base font family} 16 | 17 | \item{light}{\code{logical}. Light or dark theme?} 18 | } 19 | \description{ 20 | See \url{https://ethanschoonover.com/solarized/} for a 21 | description of the Solarized palette. 22 | } 23 | \details{ 24 | Plots made with this theme integrate seamlessly with the Solarized 25 | Beamer color theme. 26 | \url{https://github.com/jrnold/beamercolorthemesolarized}. 27 | There are two variations: \code{theme_solarized} is similar to 28 | to \code{\link[ggplot2]{theme_bw}()}, while \code{theme_solarized_2()} is 29 | similar to \code{\link[ggplot2]{theme_gray}()}. 30 | } 31 | \examples{ 32 | library("ggplot2") 33 | 34 | p <- ggplot(mtcars) + 35 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) 36 | 37 | # Light version with different main accent colors 38 | for (accent in names(ggthemes::ggthemes_data[["solarized"]][["accents"]])) { 39 | print(p + theme_solarized() + 40 | scale_colour_solarized(accent)) 41 | } 42 | 43 | # Dark version 44 | p + theme_solarized(light = FALSE) + 45 | scale_colour_solarized("blue") 46 | 47 | # Alternative theme 48 | p + theme_solarized_2(light = FALSE) + 49 | scale_colour_solarized("blue") 50 | } 51 | \concept{themes solarized} 52 | -------------------------------------------------------------------------------- /man/theme_solid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/theme-solid.R 3 | \name{theme_solid} 4 | \alias{theme_solid} 5 | \title{Theme with nothing other than a background color} 6 | \usage{ 7 | theme_solid(base_size = 12, base_family = "", fill = NA) 8 | } 9 | \arguments{ 10 | \item{base_size}{Base font size.} 11 | 12 | \item{base_family}{Ignored, kept for consistency with \code{\link{theme}()}.} 13 | 14 | \item{fill}{Background color of the plot.} 15 | } 16 | \description{ 17 | Theme that removes all non-geom elements (lines, text, etc), 18 | This theme is when only the geometric objects are desired. 19 | } 20 | \examples{ 21 | library("ggplot2") 22 | 23 | ggplot(mtcars, aes(wt, mpg)) + 24 | geom_point() + 25 | theme_solid(fill = "white") 26 | 27 | ggplot(mtcars, aes(wt, mpg)) + 28 | geom_point(color = "white") + 29 | theme_solid(fill = "black") 30 | } 31 | \seealso{ 32 | Other themes: 33 | \code{\link{theme_base}()}, 34 | \code{\link{theme_clean}()}, 35 | \code{\link{theme_foundation}()}, 36 | \code{\link{theme_igray}()}, 37 | \code{\link{theme_par}()} 38 | } 39 | \concept{themes} 40 | -------------------------------------------------------------------------------- /man/theme_stata.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stata.R 3 | \name{theme_stata} 4 | \alias{theme_stata} 5 | \title{Themes based on Stata graph schemes} 6 | \usage{ 7 | theme_stata(base_size = 11, base_family = "sans", scheme = "s2color") 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | 14 | \item{scheme}{One of "s2color", "s2mono", "s1color", 15 | "s1rcolor", or "s1mono", "s2manual", 16 | "s1manual", or "sj"} 17 | } 18 | \description{ 19 | Themes based on Stata graph schemes 20 | } 21 | \details{ 22 | These themes approximate Stata schemes using the features 23 | \pkg{ggplot2}. The graphical models of Stata and ggplot2 differ 24 | in various ways that make an exact replication impossible (or 25 | more difficult than it is worth). 26 | Some features in Stata schemes not in ggplot2: 27 | defaults for specific graph types, different levels of titles, 28 | captions and notes. These themes also adopt some of the ggplot2 29 | defaults, and more effort was made to match the colors and sizes 30 | of major elements than in matching the margins. 31 | } 32 | \examples{ 33 | library("ggplot2") 34 | 35 | p <- ggplot(mtcars) + 36 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 37 | facet_wrap(~am) + 38 | labs( 39 | title = "Graphs by car type", 40 | x = "Weight (lbs.)", y = "MPG" 41 | ) 42 | 43 | # s2color 44 | p + theme_stata() + 45 | scale_colour_stata("s2color") 46 | # s2mono 47 | p + theme_stata(scheme = "s2mono") + 48 | scale_colour_stata("mono") 49 | # s1color 50 | p + theme_stata(scheme = "s2color") + 51 | scale_colour_stata("s1color") 52 | # s1rcolor 53 | p + theme_stata(scheme = "s1rcolor") + 54 | scale_colour_stata("s1rcolor") 55 | # s1mono 56 | p + theme_stata(scheme = "s1mono") + 57 | scale_colour_stata("mono") 58 | } 59 | \references{ 60 | \url{https://www.stata.com/help.cgi?schemes} 61 | } 62 | \concept{themes stata} 63 | -------------------------------------------------------------------------------- /man/theme_tufte.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tufte.R 3 | \name{theme_tufte} 4 | \alias{theme_tufte} 5 | \title{Tufte Maximal Data, Minimal Ink Theme} 6 | \usage{ 7 | theme_tufte(base_size = 11, base_family = "serif", ticks = TRUE) 8 | } 9 | \arguments{ 10 | \item{base_size}{base font size, given in pts.} 11 | 12 | \item{base_family}{base font family} 13 | 14 | \item{ticks}{\code{logical} Show axis ticks?} 15 | } 16 | \description{ 17 | Theme based on Chapter 6 'Data-Ink Maximization and Graphical 18 | Design' of Edward Tufte *The Visual Display of Quantitative 19 | Information*. No border, no axis lines, no grids. This theme works 20 | best in combination with \code{\link{geom_rug}()} or 21 | \code{\link{geom_rangeframe}()}. 22 | } 23 | \note{ 24 | The default font family is set to 'serif' as he uses serif fonts 25 | for labels in 'The Visual Display of Quantitative Information'. 26 | The serif font used by Tufte in his books is a variant of Bembo, 27 | while the sans serif font is Gill Sans. If these fonts are 28 | installed on your system, then you can use them with the package 29 | \bold{extrafont}. 30 | } 31 | \examples{ 32 | library("ggplot2") 33 | 34 | p <- ggplot(mtcars, aes(x = wt, y = mpg)) + 35 | geom_point() + 36 | scale_x_continuous(breaks = extended_range_breaks()(mtcars$wt)) + 37 | scale_y_continuous(breaks = extended_range_breaks()(mtcars$mpg)) + 38 | ggtitle("Cars") 39 | 40 | p + geom_rangeframe() + 41 | coord_cartesian(clip = "off") + 42 | theme_tufte() 43 | 44 | p + geom_rug() + 45 | theme_tufte(ticks = FALSE) 46 | } 47 | \references{ 48 | Tufte, Edward R. (2001) The Visual Display of 49 | Quantitative Information, Chapter 6. 50 | } 51 | \concept{themes tufte} 52 | -------------------------------------------------------------------------------- /man/theme_wsj.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/wsj.R 3 | \name{theme_wsj} 4 | \alias{theme_wsj} 5 | \title{Wall Street Journal theme} 6 | \usage{ 7 | theme_wsj( 8 | base_size = 12, 9 | color = "brown", 10 | base_family = "sans", 11 | title_family = "mono" 12 | ) 13 | } 14 | \arguments{ 15 | \item{base_size}{base font size, given in pts.} 16 | 17 | \item{color}{The background color of plot. One of \code{'brown', 18 | 'gray', 'green', 'blue'}.} 19 | 20 | \item{base_family}{base font family} 21 | 22 | \item{title_family}{Plot title font family.} 23 | } 24 | \description{ 25 | Theme based on the plots in \emph{The Wall Street Journal}. 26 | } 27 | \details{ 28 | This theme should be used with \code{\link{scale_color_wsj}()}. 29 | } 30 | \examples{ 31 | library("ggplot2") 32 | 33 | p <- ggplot(mtcars) + 34 | geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + 35 | facet_wrap(~am) + 36 | ggtitle("Diamond Prices") 37 | p + scale_colour_wsj("colors6", "") + theme_wsj() 38 | # Use a gray background instead 39 | p + scale_colour_wsj("colors6", "") + theme_wsj(color = "gray") 40 | } 41 | \references{ 42 | \url{https://twitter.com/WSJGraphics} 43 | 44 | \url{https://pinterest.com/wsjgraphics/wsj-graphics/} 45 | } 46 | \concept{themes wsj} 47 | -------------------------------------------------------------------------------- /man/tremmel_shape_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/shapes.R 3 | \name{tremmel_shape_pal} 4 | \alias{tremmel_shape_pal} 5 | \title{Shape palette from Tremmel (1995) (discrete)} 6 | \usage{ 7 | tremmel_shape_pal(overlap = FALSE, alt = FALSE) 8 | } 9 | \arguments{ 10 | \item{overlap}{use an empty circle instead of a solid circle when 11 | \code{n == 2}.} 12 | 13 | \item{alt}{If \code{TRUE}, then when \code{n == 3}, 14 | use a solid circle, plus sign and 15 | empty triangle. Otherwise use a solid circle, empty circle, and empty 16 | triangle.} 17 | } 18 | \description{ 19 | Based on experiments Tremmel (1995) suggests the following shape palettes: 20 | } 21 | \details{ 22 | If two symbols, then use a solid circle and plus sign. 23 | 24 | If three symbols, then use a solid circle, empty circle, and an 25 | empty triangle. However, that set of symbols does not satisfy the 26 | requirement that each symbol should differ from the other symbols 27 | in the same feature dimension. A set of three symbols that 28 | satisfies this is a circle (curvature), plus sign (number of 29 | terminators), triangle (line orientation). 30 | 31 | This palette supports up to three values. 32 | If more than three groups of data, then separate the groups into 33 | different plots. 34 | } 35 | \references{ 36 | Tremmel, Lothar, (1995) "The Visual Separability of Plotting Symbols in Scatterplots" 37 | Journal of Computational and Graphical Statistics, 38 | \url{https://www.jstor.org/stable/1390760} 39 | } 40 | \seealso{ 41 | Other shapes: 42 | \code{\link{circlefill_shape_pal}()}, 43 | \code{\link{cleveland_shape_pal}()}, 44 | \code{\link{scale_shape_circlefill}()}, 45 | \code{\link{scale_shape_cleveland}()}, 46 | \code{\link{scale_shape_tremmel}()} 47 | } 48 | \concept{shapes} 49 | -------------------------------------------------------------------------------- /man/wsj_pal.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/wsj.R 3 | \name{wsj_pal} 4 | \alias{wsj_pal} 5 | \title{Wall Street Journal color palette (discrete)} 6 | \usage{ 7 | wsj_pal(palette = "colors6") 8 | } 9 | \arguments{ 10 | \item{palette}{\code{character} The color palette to use: . 11 | \Sexpr[results=rd]{ggthemes:::rd_optlist(names(ggthemes::ggthemes_data$wsj$palettes))}} 12 | } 13 | \description{ 14 | The Wall Street Journal uses many different color palettes in its 15 | plots. This collects a few of them, but is by no means exhaustive. 16 | Collections of these plots can be found on the WSJ Graphics 17 | \href{https://twitter.com/WSJGraphics}{Twitter} feed and 18 | \href{https://pinterest.com/wsjgraphics/wsj-graphics/}{Pinterest}. 19 | } 20 | \section{Palettes}{ 21 | 22 | 23 | The following palettes are defined, 24 | 25 | \describe{ 26 | \item{rgby}{Red/Green/Blue/Yellow theme.} 27 | \item{red_green}{Green/red two-color scale for good/bad.} 28 | \item{green_black}{Black-green 4-color scale for 'Very negative', 29 | 'Somewhat negative', 'somewhat positive', 'very positive'.} 30 | \item{dem_rep}{Democrat/Republican/Undecided blue/red/gray scale.} 31 | \item{colors6}{Red, blue, gold, green, orange, and black palette.} 32 | } 33 | } 34 | 35 | \seealso{ 36 | Other colour wsj: 37 | \code{\link{scale_colour_wsj}()} 38 | } 39 | \concept{colour wsj} 40 | -------------------------------------------------------------------------------- /scripts/style.R: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | styler::style_pkg(".", style = styler::tidyverse_style, strict = TRUE) 3 | styler::style_dir("inst/examples/", exclude_files = 4 | c("ex-few_shape_pal.R", 5 | "ex-calc_shape_pal.R", 6 | "ex-cleveland_shape_pal.R", 7 | "ex-few_shape_pal.R", 8 | "ex-palette_pander.R", 9 | "ex-scale_shape_stata.R", 10 | "ex-scale_shape_tableau.R", 11 | "ex-tableau_shape_pal.R", 12 | "ex-tableau_shape_pal.R", 13 | "ex-theme_calc.R", 14 | "ex-theme_economist.R")) 15 | -------------------------------------------------------------------------------- /tests/figs/deps.txt: -------------------------------------------------------------------------------- 1 | - vdiffr-svg-engine: 1.0 2 | - vdiffr: 0.3.0 3 | - freetypeharfbuzz: 0.2.5 4 | -------------------------------------------------------------------------------- /tests/spelling.R: -------------------------------------------------------------------------------- 1 | if (requireNamespace("spelling", quietly = TRUE)) { 2 | spelling::spell_check_test( 3 | vignettes = TRUE, error = FALSE, 4 | skip_on_cran = TRUE 5 | ) 6 | } 7 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | # This file is part of the standard setup for testthat. 2 | # It is recommended that you do not modify it. 3 | # 4 | # Where should you do additional test configuration? 5 | # Learn more about the roles of various files in: 6 | # * https://r-pkgs.org/testing-design.html#sec-tests-files-overview 7 | # * https://testthat.r-lib.org/articles/special-files.html 8 | 9 | library(testthat) 10 | library(ggthemes) 11 | 12 | test_check("ggthemes") 13 | -------------------------------------------------------------------------------- /tests/testthat/_snaps/shapes.md: -------------------------------------------------------------------------------- 1 | # circlefill_pal works 2 | 3 | Code 4 | pal <- circlefill_shape_pal() 5 | Condition 6 | Warning: 7 | `circlefill_shape_pal()` was deprecated in ggthemes 5.0.0. 8 | Code 9 | expect_type(pal, "closure") 10 | expect_equal(attr(pal, "max_n"), 5L) 11 | n <- 4L 12 | values <- pal(n) 13 | expect_type(values, "integer") 14 | expect_equal(length(values), n) 15 | 16 | # scale_shape_circlefill works 17 | 18 | Code 19 | expect_s3_class(scale_shape_circlefill(), "ScaleDiscrete") 20 | Condition 21 | Warning: 22 | `scale_shape_circlefill()` was deprecated in ggthemes 5.0.0. 23 | Warning: 24 | `circlefill_shape_pal()` was deprecated in ggthemes 5.0.0. 25 | 26 | -------------------------------------------------------------------------------- /tests/testthat/helper-utils.R: -------------------------------------------------------------------------------- 1 | library("testthat") 2 | 3 | is_hexcolor <- function(x) { 4 | pattern <- stringr::regex("^#[a-f0-9]{6}$", ignore_case = TRUE) 5 | out <- stringr::str_detect(x, pattern) 6 | out[is.na(out)] <- FALSE 7 | out 8 | } 9 | 10 | expect_hexcolor <- function(object) { 11 | # capture object and label 12 | act <- quasi_label(rlang::enquo(object)) 13 | 14 | valid <- is_hexcolor(act$val) 15 | expect( 16 | all(valid), 17 | glue::glue("Not all elements of {act$lab} are hex colors.") 18 | ) 19 | 20 | invisible(act$val) 21 | } 22 | 23 | expect_equal_scale <- function(x, y, ...) { 24 | x <- as.list(x) 25 | y <- as.list(y) 26 | x$call <- y$call <- NULL 27 | expect_equal(x, y, ...) 28 | } 29 | -------------------------------------------------------------------------------- /tests/testthat/helper-vdiffr.R: -------------------------------------------------------------------------------- 1 | expect_doppelganger <- function(title, fig, path = NULL) { 2 | # need to call conditionally because vdiffr listed in Suggests (#124) 3 | testthat::skip_if_not_installed("vdiffr") 4 | vdiffr::expect_doppelganger(title, fig) 5 | } 6 | -------------------------------------------------------------------------------- /tests/testthat/test-banking.R: -------------------------------------------------------------------------------- 1 | test_that("bank_slopes runs", { 2 | x <- 1:5 3 | y <- runif(length(x)) 4 | out <- bank_slopes(x, y) 5 | expect_equal(length(out), 1L) 6 | expect_type(out, "double") 7 | }) 8 | 9 | test_that("bank_slopes with method=\"as\" runs", { 10 | x <- 1:5 11 | y <- runif(length(x)) 12 | out <- bank_slopes(x, y, method = "as") 13 | expect_equal(length(out), 1L) 14 | expect_type(out, "double") 15 | }) 16 | 17 | test_that("bank_slopes with invalid method throws error", { 18 | expect_error(bank_slopes(1:5, 1:5, method = "aor")) 19 | }) 20 | 21 | test_that("bank_slopes works with cull = TRUE", { 22 | x <- c(1, 1, 2) 23 | y <- runif(length(x)) 24 | out <- bank_slopes(x, y, cull = TRUE) 25 | expect_equal(length(out), 1L) 26 | expect_type(out, "double") 27 | }) 28 | -------------------------------------------------------------------------------- /tests/testthat/test-base.R: -------------------------------------------------------------------------------- 1 | test_that("theme_base runs", { 2 | expect_s3_class(theme_base(), "theme") 3 | }) 4 | 5 | test_that("theme_par runs", { 6 | expect_s3_class(theme_par(), "theme") 7 | }) 8 | 9 | 10 | test_that("theme_par recognizes las", { 11 | withr::with_par(list(las = 1), { 12 | thm <- theme_par() 13 | expect_equal(thm$axis.title.x$angle, 0) 14 | expect_equal(thm$axis.title.y$angle, 0) 15 | }) 16 | withr::with_par(list(las = 2), { 17 | thm <- theme_par() 18 | expect_equal(thm$axis.title.x$angle, 90) 19 | expect_equal(thm$axis.title.y$angle, 0) 20 | }) 21 | withr::with_par(list(las = 3), { 22 | thm <- theme_par() 23 | expect_equal(thm$axis.title.x$angle, 90) 24 | expect_equal(thm$axis.title.y$angle, 90) 25 | }) 26 | }) 27 | 28 | test_that("theme_par recognizes tck", { 29 | withr::with_par(list(tck = 1), { 30 | expect_equal(theme_par()$axis.ticks.length, grid::unit(-1, "snpc")) 31 | }) 32 | }) 33 | 34 | test_that("theme_par recognizes xaxt", { 35 | withr::with_par(list(xaxt = "n"), { 36 | thm <- theme_par() 37 | for (i in c("axis.line.x", "axis.text.x", "axis.ticks.x")) { 38 | expect_equal(thm[[i]], element_blank()) 39 | } 40 | }) 41 | }) 42 | 43 | test_that("theme_par recognizes yaxt", { 44 | withr::with_par(list(yaxt = "n"), { 45 | thm <- theme_par() 46 | for (i in c("axis.line.y", "axis.text.y", "axis.ticks.y")) { 47 | expect_equal(thm[[i]], element_blank()) 48 | } 49 | }) 50 | }) 51 | -------------------------------------------------------------------------------- /tests/testthat/test-calc.R: -------------------------------------------------------------------------------- 1 | test_that("calc_shape_pal works", { 2 | pal <- calc_shape_pal() 3 | expect_type(pal, "closure") 4 | expect_type(attr(pal, "max_n"), "integer") 5 | n <- 5L 6 | shapes <- pal(n) 7 | expect_type(shapes, "integer") 8 | expect_true(all(shapes < 0)) 9 | expect_equal(length(shapes), n) 10 | }) 11 | 12 | test_that("calc_pal works", { 13 | pal <- calc_pal() 14 | expect_type(pal, "closure") 15 | expect_type(attr(pal, "max_n"), "integer") 16 | n <- 5L 17 | expect_hexcolor(pal(n)) 18 | expect_warning(pal(100)) 19 | expect_error(pal(-1)) 20 | }) 21 | 22 | test_that("calc_shape_pal raises warning for large n", { 23 | expect_warning(calc_shape_pal()(100)) 24 | }) 25 | 26 | test_that("theme_calc works", { 27 | expect_s3_class(theme_calc(), "theme") 28 | }) 29 | 30 | test_that("scale_colour_calc works", { 31 | expect_s3_class(scale_colour_calc(), "ScaleDiscrete") 32 | }) 33 | 34 | test_that("scale_fill_calc works", { 35 | expect_s3_class(scale_fill_calc(), "ScaleDiscrete") 36 | }) 37 | 38 | test_that("scale_shape_calc works", { 39 | expect_s3_class(scale_shape_calc(), "ScaleDiscrete") 40 | }) 41 | -------------------------------------------------------------------------------- /tests/testthat/test-canva.R: -------------------------------------------------------------------------------- 1 | test_that("canva_pal works", { 2 | p <- canva_pal() 3 | expect_type(p, "closure") 4 | expect_hexcolor(p(4)) 5 | }) 6 | 7 | test_that("canva_pal works with alt palette", { 8 | expect_hexcolor(canva_pal("Pop art")(4)) 9 | }) 10 | 11 | test_that("canva_pal raises warning with to large n", { 12 | expect_warning(canva_pal()(10)) 13 | }) 14 | 15 | 16 | test_that("canva_pal raises error with invalid palette", { 17 | expect_error(canva_pal("adsffafd"), regexp = "not a valid name") 18 | }) 19 | 20 | test_that("scale_colour_canva works", { 21 | expect_s3_class(scale_colour_canva(), "ScaleDiscrete") 22 | }) 23 | 24 | test_that("scale_color_canva works", { 25 | expect_equal_scale(scale_color_canva(), scale_colour_canva()) 26 | }) 27 | 28 | test_that("scale_colour_canva works", { 29 | expect_s3_class(scale_fill_canva(), "ScaleDiscrete") 30 | }) 31 | -------------------------------------------------------------------------------- /tests/testthat/test-colorblind.R: -------------------------------------------------------------------------------- 1 | test_that("colorblind_pal works", { 2 | p <- colorblind_pal() 3 | expect_type(p, "closure") 4 | expect_hexcolor(p(4)) 5 | expect_type(attr(p, "max_n"), "integer") 6 | }) 7 | 8 | test_that("colorblind_pal raises warning with to large n", { 9 | expect_warning(colorblind_pal()(20)) 10 | }) 11 | 12 | test_that("scale_colour_colorblind works", { 13 | expect_s3_class(scale_colour_colorblind(), "ScaleDiscrete") 14 | }) 15 | 16 | test_that("scale_color_canva works", { 17 | expect_equal_scale(scale_color_colorblind(), scale_colour_colorblind()) 18 | }) 19 | 20 | test_that("scale_fill_colorblind works", { 21 | expect_s3_class(scale_fill_colorblind(), "ScaleDiscrete") 22 | }) 23 | -------------------------------------------------------------------------------- /tests/testthat/test-economist.R: -------------------------------------------------------------------------------- 1 | test_that("economist_pal fill=FALSE works", { 2 | p <- economist_pal(fill = FALSE) 3 | expect_type(p, "closure") 4 | for (i in 1:9) { 5 | expect_hexcolor(p(i)) 6 | } 7 | }) 8 | 9 | test_that("economist_pal fill=TRUE works", { 10 | p <- economist_pal(fill = TRUE) 11 | expect_type(p, "closure") 12 | for (i in 1:9) { 13 | expect_hexcolor(p(i)) 14 | } 15 | }) 16 | 17 | test_that("economist_pal raises warning with large number", { 18 | expect_warning(economist_pal()(10)) 19 | }) 20 | 21 | test_that("scale_colour_economist equals scale_color_economist", { 22 | expect_equal_scale(scale_color_economist(), scale_colour_economist()) 23 | }) 24 | 25 | test_that("scale_colour_economist works", { 26 | expect_s3_class(scale_color_economist(), "ScaleDiscrete") 27 | }) 28 | 29 | test_that("scale_fill_economist works", { 30 | expect_s3_class(scale_fill_economist(), "ScaleDiscrete") 31 | }) 32 | 33 | test_that("theme economist works", { 34 | expect_s3_class(theme_economist(), "theme") 35 | }) 36 | 37 | test_that("theme economist with horizontal=FALSE works", { 38 | thm <- theme_economist(horizontal = FALSE) 39 | expect_s3_class(thm, "theme") 40 | expect_equal(thm$panel.grid.major.y, element_blank()) 41 | }) 42 | 43 | test_that("theme economist with dark panel works", { 44 | thm <- theme_economist(dkpanel = TRUE) 45 | expect_s3_class(thm, "theme") 46 | expect_equal( 47 | thm$strip.background$fill, 48 | purrr::pluck(dplyr::filter( 49 | ggthemes_data$economist$bg, 50 | name == "dark blue-gray" 51 | ), "value") 52 | ) 53 | }) 54 | 55 | test_that("theme economist_white works", { 56 | thm <- theme_economist_white(gray_bg = FALSE) 57 | 58 | expect_equal(thm$panel.background$fill, "white") 59 | expect_equal(thm$plot.background$fill, "white") 60 | }) 61 | 62 | test_that("theme economist_white with gray background works", { 63 | thm <- theme_economist_white(gray_bg = TRUE) 64 | expect_s3_class(thm, "theme") 65 | expect_equal( 66 | thm$plot.background$fill, 67 | purrr::pluck(dplyr::filter( 68 | ggthemes_data$economist$bg, 69 | name == "light gray" 70 | ), "value") 71 | ) 72 | }) 73 | -------------------------------------------------------------------------------- /tests/testthat/test-excel.R: -------------------------------------------------------------------------------- 1 | test_that("excel_clasic_pal works", { 2 | pal <- excel_pal() 3 | n <- 5L 4 | values <- pal(n) 5 | expect_type(values, "character") 6 | expect_equal(length(values), n) 7 | }) 8 | 9 | test_that("excel_clasic_pal with line = TRUE works", { 10 | pal <- excel_pal(line = TRUE) 11 | n <- 5L 12 | values <- pal(n) 13 | expect_type(values, "character") 14 | expect_equal(length(values), n) 15 | }) 16 | 17 | test_that("calc_shape_pal raises warning for large n", { 18 | expect_warning(excel_pal()(8)) 19 | }) 20 | 21 | test_that("excel_new_pal works", { 22 | pal <- excel_new_pal() 23 | n <- 5L 24 | vals <- pal(n) 25 | expect_type(vals, "character") 26 | expect_equal(length(vals), n) 27 | }) 28 | 29 | test_that("excel_new_pal raises error for bad n", { 30 | expect_warning(excel_new_pal()(7)) 31 | }) 32 | 33 | test_that("theme_excel works", { 34 | expect_s3_class(theme_excel(), "theme") 35 | }) 36 | 37 | test_that("excel_new_pal raises error with bad theme name", { 38 | expect_error(excel_new_pal("adfaasdfa"), regexp = "`theme` must be one of") 39 | }) 40 | 41 | test_that("scale_fill_excel works", { 42 | expect_s3_class(scale_fill_excel(), "ScaleDiscrete") 43 | }) 44 | 45 | test_that("scale_colour_excel works", { 46 | expect_s3_class(scale_colour_excel(), "ScaleDiscrete") 47 | }) 48 | 49 | test_that("scale_colour_excel works", { 50 | expect_s3_class(scale_fill_excel_new(), "ScaleDiscrete") 51 | }) 52 | 53 | test_that("scale_fill_excel works", { 54 | expect_s3_class(scale_colour_excel_new(), "ScaleDiscrete") 55 | }) 56 | 57 | test_that("theme_excel with horizontal = FALSE works", { 58 | thm <- theme_excel(horizontal = FALSE) 59 | expect_equal(thm$panel.grid.major.y, element_blank()) 60 | }) 61 | -------------------------------------------------------------------------------- /tests/testthat/test-few.R: -------------------------------------------------------------------------------- 1 | library("ggplot2") 2 | 3 | test_that("few_shape_pal works", { 4 | out <- few_shape_pal() 5 | expect_type(out, "closure") 6 | expect_true(!is.null(attr(out, "max_n"))) 7 | 8 | pal0 <- out(0) 9 | expect_identical(length(pal0), 0L) 10 | pal3 <- out(3) 11 | expect_identical(length(pal3), 3L) 12 | expect_warning(out(10)) 13 | }) 14 | 15 | test_that("few_shape_pal works", { 16 | out <- scale_shape_few() 17 | expect_s3_class(out, c("ScaleDiscrete", "Scale", "ggproto")) 18 | }) 19 | 20 | test_that("few_pal runs", { 21 | p <- few_pal("Medium") 22 | expect_type(p, "closure") 23 | expect_type(attr(p, "max_n"), "integer") 24 | out <- p(5) 25 | expect_type(out, "character") 26 | expect_equal(length(out), 5L) 27 | # should use the first accent color 28 | expect_equal( 29 | out[[1]], 30 | ggthemes::ggthemes_data$few$colors$Medium$value[[2]] 31 | ) 32 | expect_warning(p(10)) 33 | }) 34 | 35 | test_that("few_pal works with n = 1", { 36 | out <- few_pal("Medium")(1) 37 | expect_equal(out, ggthemes::ggthemes_data$few$colors$Medium$value[[1]]) 38 | }) 39 | 40 | test_that("few_pal raises error with bad palette", { 41 | expect_error(few_pal("Foo")) 42 | }) 43 | 44 | test_that("scale_colour_few works", { 45 | expect_s3_class(scale_colour_few(), "ScaleDiscrete") 46 | }) 47 | 48 | test_that("scale_color_few works", { 49 | expect_equal_scale(scale_color_few(), scale_colour_few()) 50 | }) 51 | 52 | test_that("scale_fill_few works", { 53 | expect_s3_class(scale_fill_few(), "ScaleDiscrete") 54 | }) 55 | 56 | test_that("theme_few works", { 57 | expect_s3_class(theme_few(), "theme") 58 | }) 59 | 60 | test_that("theme_few draws correctly", { 61 | df <- data.frame(x = 1:3, y = 1:3, z = c("a", "b", "a"), a = 1) 62 | plot <- ggplot(df, aes(x, y, colour = z)) + 63 | geom_point() + 64 | facet_wrap(~a) 65 | expect_doppelganger("theme_few", plot) 66 | }) 67 | -------------------------------------------------------------------------------- /tests/testthat/test-fivethirtyeight.R: -------------------------------------------------------------------------------- 1 | test_that("theme_fivethirtyeight works", { 2 | expect_s3_class(theme_fivethirtyeight(), "theme") 3 | }) 4 | 5 | test_that("scale_fill_fivethirtyeight works", { 6 | expect_s3_class(scale_fill_fivethirtyeight(), "ScaleDiscrete") 7 | }) 8 | 9 | test_that("scale_colour_fivethirtyeight works", { 10 | expect_s3_class(scale_colour_fivethirtyeight(), "ScaleDiscrete") 11 | }) 12 | 13 | test_that("fivethirtyeight_pal works", { 14 | p <- fivethirtyeight_pal() 15 | expect_type(p, "closure") 16 | expect_type(attr(p, "max_n"), "integer") 17 | expect_hexcolor(p(3)) 18 | }) 19 | -------------------------------------------------------------------------------- /tests/testthat/test-gdocs.R: -------------------------------------------------------------------------------- 1 | test_that("gdocs_pal works", { 2 | pal <- gdocs_pal() 3 | expect_type(pal, "closure") 4 | n <- 3 5 | vals <- pal(n) 6 | expect_type(vals, "character") 7 | expect_equal(length(vals), n) 8 | }) 9 | 10 | test_that("scale_fill_gdocs works", { 11 | expect_s3_class(scale_fill_gdocs(), "ScaleDiscrete") 12 | }) 13 | 14 | test_that("scale_colour_gdocs works", { 15 | expect_s3_class(scale_fill_gdocs(), "ScaleDiscrete") 16 | }) 17 | 18 | test_that("scale_color_gdocs works", { 19 | expect_equal_scale(scale_color_gdocs(), scale_colour_gdocs()) 20 | }) 21 | 22 | test_that("theme_gdocs works", { 23 | expect_s3_class(theme_gdocs(), "theme") 24 | }) 25 | -------------------------------------------------------------------------------- /tests/testthat/test-geom-rangeframe.R: -------------------------------------------------------------------------------- 1 | test_that("geom_rangeframe works", { 2 | expect_s3_class(geom_rangeframe(), "LayerInstance") 3 | }) 4 | -------------------------------------------------------------------------------- /tests/testthat/test-hc.R: -------------------------------------------------------------------------------- 1 | test_that("hc_pal works", { 2 | pal <- hc_pal() 3 | expect_type(pal, "closure") 4 | n <- 5 5 | values <- pal(n) 6 | expect_type(values, "character") 7 | expect_equal(length(values), n) 8 | }) 9 | 10 | test_that("hc_pal raises error with invalid palette", { 11 | expect_error(hc_pal(palette = "asdgasdgasdgas"), 12 | regexp = "not valid" 13 | ) 14 | }) 15 | 16 | test_that("scale_colour_hc works", { 17 | expect_s3_class(scale_colour_hc(), "ScaleDiscrete") 18 | }) 19 | 20 | test_that("scale_color_hc works", { 21 | expect_equal_scale(scale_colour_hc(), scale_color_hc()) 22 | }) 23 | 24 | test_that("scale_fill_hc works", { 25 | expect_s3_class(scale_fill_hc(), "ScaleDiscrete") 26 | }) 27 | 28 | test_that("theme_hc works", { 29 | expect_s3_class(theme_hc(), "theme") 30 | expect_s3_class(theme_hc(style = "darkunica"), "theme") 31 | }) 32 | 33 | test_that("bgcolor raises warning", { 34 | expect_warning(theme_hc(bgcolor = "darkunica"), regexp = "deprecated") 35 | }) 36 | -------------------------------------------------------------------------------- /tests/testthat/test-igray.R: -------------------------------------------------------------------------------- 1 | test_that("theme_igray works", { 2 | thm <- theme_igray() 3 | expect_s3_class(thm, "theme") 4 | expect_equal(thm$plot.background$fill, "gray90") 5 | }) 6 | -------------------------------------------------------------------------------- /tests/testthat/test-pander.R: -------------------------------------------------------------------------------- 1 | test_that("scale_colour_pander works", { 2 | expect_s3_class(scale_colour_pander(), "ScaleDiscrete") 3 | }) 4 | 5 | test_that("scale_fill_pander works", { 6 | expect_s3_class(scale_fill_pander(), "ScaleDiscrete") 7 | }) 8 | 9 | test_that("palette_pander works", { 10 | colors <- palette_pander(5) 11 | expect_hexcolor(colors) 12 | }) 13 | 14 | test_that("palette_pander random_order=TRUE works", { 15 | colors <- palette_pander(5, random_order = TRUE) 16 | expect_hexcolor(colors) 17 | }) 18 | 19 | test_that("theme_pander works", { 20 | expect_s3_class(theme_pander(), "theme") 21 | }) 22 | 23 | test_that("theme_pander works with gm = FALSE", { 24 | thm <- theme_pander(gM = FALSE) 25 | expect_s3_class(thm, "theme") 26 | expect_equal(thm$panel.grid, element_blank()) 27 | }) 28 | 29 | 30 | test_that("theme_pander warns about ff argument", { 31 | expect_warning(theme_pander(ff = ""), regexp = "deprecated") 32 | }) 33 | 34 | test_that("theme_pander warns about fs argument", { 35 | expect_warning(theme_pander(fs = 1), regexp = "deprecated") 36 | }) 37 | -------------------------------------------------------------------------------- /tests/testthat/test-ptol.R: -------------------------------------------------------------------------------- 1 | test_that("ptol_pal works", { 2 | p <- ptol_pal() 3 | expect_type(p, "closure") 4 | expect_type(attr(p, "max_n"), "integer") 5 | expect_hexcolor(p(11)) 6 | }) 7 | 8 | test_that("scale_colour_ptol works", { 9 | expect_s3_class(scale_colour_ptol(), "ScaleDiscrete") 10 | }) 11 | 12 | test_that("scale_fill_ptol works", { 13 | expect_s3_class(scale_fill_ptol(), "ScaleDiscrete") 14 | }) 15 | -------------------------------------------------------------------------------- /tests/testthat/test-shapes.R: -------------------------------------------------------------------------------- 1 | test_that("circlefill_pal works", { 2 | expect_snapshot({ 3 | pal <- circlefill_shape_pal() 4 | expect_type(pal, "closure") 5 | expect_equal(attr(pal, "max_n"), 5L) 6 | n <- 4L 7 | values <- pal(n) 8 | expect_type(values, "integer") 9 | expect_equal(length(values), n) 10 | }) 11 | }) 12 | 13 | test_that("scale_shape_circlefill works", { 14 | expect_snapshot({ 15 | expect_s3_class(scale_shape_circlefill(), "ScaleDiscrete") 16 | }) 17 | }) 18 | 19 | test_that("tremmel_shape_pal works", { 20 | pal <- tremmel_shape_pal() 21 | expect_type(pal, "closure") 22 | expect_equal(attr(pal, "max_n"), 3L) 23 | n <- 3L 24 | values <- pal(n) 25 | expect_type(values, "integer") 26 | expect_equal(length(values), n) 27 | }) 28 | 29 | test_that("tremmel_shape_pal works for all values", { 30 | for (i in 1:3L) { 31 | expect_equal(length(tremmel_shape_pal()(i)), i) 32 | expect_equal(length(tremmel_shape_pal(alt = TRUE)(i)), i) 33 | expect_equal(length(tremmel_shape_pal(overlap = TRUE)(i)), i) 34 | } 35 | }) 36 | 37 | test_that("scale_shape_tremmel works", { 38 | expect_s3_class(scale_shape_tremmel(), "ScaleDiscrete") 39 | }) 40 | 41 | test_that("cleveland_shape_pal works", { 42 | pal <- cleveland_shape_pal() 43 | expect_type(pal, "closure") 44 | expect_equal(attr(pal, "max_n"), 4) 45 | n <- 3 46 | vals <- pal(n) 47 | expect_equal(length(vals), n) 48 | }) 49 | 50 | 51 | 52 | test_that("cleveland_shape_pal works with overlap = FALSE", { 53 | pal <- cleveland_shape_pal(overlap = FALSE) 54 | expect_type(pal, "closure") 55 | expect_equal(attr(pal, "max_n"), 5) 56 | n <- 3 57 | vals <- pal(n) 58 | expect_equal(length(vals), n) 59 | expect_type(vals, "integer") 60 | expect_true(all(vals < 0)) 61 | }) 62 | 63 | test_that("scale_shape_cleveland works", { 64 | expect_s3_class(scale_shape_cleveland(), "ScaleDiscrete") 65 | }) 66 | -------------------------------------------------------------------------------- /tests/testthat/test-show.R: -------------------------------------------------------------------------------- 1 | test_that("show_shapes works", { 2 | # creates plot using base plotting system, so just run code --- any 3 | # errors / warnings will be caught. 4 | x <- 1:10 5 | expect_equal(show_shapes(x), x) 6 | }) 7 | 8 | test_that("show_linetypes works", { 9 | x <- 1:5 10 | expect_equal(show_linetypes(x), x) 11 | }) 12 | 13 | test_that("show_linetypes works with labels = FALSE", { 14 | x <- 1:5 15 | expect_equal(show_linetypes(x, labels = FALSE), x) 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-solarized.R: -------------------------------------------------------------------------------- 1 | test_that("theme_solarized_works", { 2 | expect_s3_class(theme_solarized(), "theme") 3 | expect_s3_class(theme_solarized(light = FALSE), "theme") 4 | }) 5 | 6 | test_that("theme_solarized_2_works", { 7 | expect_s3_class(theme_solarized_2(), "theme") 8 | expect_s3_class(theme_solarized_2(light = FALSE), "theme") 9 | }) 10 | 11 | test_that("scale_colour_solarized works", { 12 | expect_s3_class(scale_colour_solarized(), "ScaleDiscrete") 13 | }) 14 | 15 | test_that("scale_color_solarized works", { 16 | expect_equal_scale(scale_colour_solarized(), scale_color_solarized()) 17 | }) 18 | 19 | test_that("scale_fill_solarized works", { 20 | expect_s3_class(scale_fill_solarized(), "ScaleDiscrete") 21 | }) 22 | 23 | test_that("solarized_pal works", { 24 | pal <- solarized_pal() 25 | expect_type(pal, "closure") 26 | n <- 5L 27 | values <- pal(n) 28 | expect_type(values, "character") 29 | expect_equal(length(values), n) 30 | }) 31 | -------------------------------------------------------------------------------- /tests/testthat/test-stat_fivenumber.R: -------------------------------------------------------------------------------- 1 | test_that("stat_fivenumber works", { 2 | expect_s3_class(stat_fivenumber(), "LayerInstance") 3 | }) 4 | -------------------------------------------------------------------------------- /tests/testthat/test-stata.R: -------------------------------------------------------------------------------- 1 | test_that("stata_pal works", { 2 | p <- stata_pal() 3 | expect_type(p, "closure") 4 | expect_type(attr(p, "max_n"), "integer") 5 | n <- 5 6 | vals <- p(n) 7 | expect_hexcolor(vals) 8 | expect_length(vals, n) 9 | expect_warning(stata_pal()(100)) 10 | }) 11 | 12 | test_that("scale_colour_stata works", { 13 | expect_s3_class(scale_colour_stata(), "ScaleDiscrete") 14 | }) 15 | 16 | test_that("scale_color_stata works", { 17 | expect_equal_scale(scale_colour_stata(), scale_color_stata()) 18 | }) 19 | 20 | test_that("scale_fill_stata works", { 21 | expect_s3_class(scale_fill_stata(), "ScaleDiscrete") 22 | }) 23 | 24 | test_that("scale_shape_stata works", { 25 | expect_s3_class(scale_shape_stata(), "ScaleDiscrete") 26 | }) 27 | 28 | test_that("theme_stata works", { 29 | expect_s3_class(theme_stata(), "theme") 30 | for (i in c("s2mono", "s1mono", "s2manual", "s1rcolor", "s1color")) { 31 | expect_s3_class(theme_stata(scheme = i), "theme") 32 | } 33 | }) 34 | 35 | test_that("theme_state raises error with invallid scheme", { 36 | expect_error(theme_stata(scheme = "dsagasagdadgaga"), 37 | regexp = "`scheme` must be one of" 38 | ) 39 | }) 40 | 41 | test_that("stata_shape_pal works", { 42 | p <- stata_shape_pal() 43 | expect_type(p, "closure") 44 | n <- 5L 45 | vals <- p(n) 46 | expect_type(vals, "integer") 47 | expect_length(vals, n) 48 | expect_true(all(vals < 0)) 49 | expect_warning(p(100)) 50 | }) 51 | 52 | test_that("stata_linetype_pal works", { 53 | p <- stata_linetype_pal() 54 | expect_type(p, "closure") 55 | n <- 5L 56 | vals <- p(n) 57 | expect_equal(vals, c("solid", "84", "23", "F414", "F4")) 58 | }) 59 | 60 | test_that("scale_linetype_stata works", { 61 | expect_s3_class(scale_linetype_stata(), "ScaleDiscrete") 62 | }) 63 | -------------------------------------------------------------------------------- /tests/testthat/test-theme_map.R: -------------------------------------------------------------------------------- 1 | test_that("theme_map works", { 2 | thm <- theme_map() 3 | expect_s3_class(thm, "theme") 4 | expect_equal(thm$panel.background, element_blank()) 5 | }) 6 | -------------------------------------------------------------------------------- /tests/testthat/test-theme_solid.R: -------------------------------------------------------------------------------- 1 | test_that("theme_solid works", { 2 | thm <- theme_solid(fill = "red") 3 | expect_s3_class(thm, "theme") 4 | expect_equal(thm$rect$fill, "red") 5 | }) 6 | -------------------------------------------------------------------------------- /tests/testthat/test-tufte.R: -------------------------------------------------------------------------------- 1 | test_that("theme_tufte works", { 2 | thm <- theme_tufte() 3 | expect_s3_class(thm, "theme") 4 | }) 5 | 6 | test_that("theme_tufte works with ticks = FALSE", { 7 | thm <- theme_tufte(ticks = FALSE) 8 | expect_s3_class(thm, "theme") 9 | expect_equal(thm$axis.ticks, element_blank()) 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test-tufteboxplot.R: -------------------------------------------------------------------------------- 1 | test_that("geom_tufteboxplot works", { 2 | expect_s3_class(geom_tufteboxplot(), "LayerInstance") 3 | }) 4 | -------------------------------------------------------------------------------- /tests/testthat/test-wsj_pal.R: -------------------------------------------------------------------------------- 1 | test_that("theme_wsj works", { 2 | expect_s3_class(theme_wsj(), "theme") 3 | }) 4 | 5 | test_that("wsj_pal works", { 6 | p <- wsj_pal() 7 | expect_type(p, "closure") 8 | expect_type(attr(p, "max_n"), "integer") 9 | expect_hexcolor(p(3)) 10 | }) 11 | 12 | test_that("theme_wsj works", { 13 | expect_s3_class(theme_wsj(), "theme") 14 | }) 15 | 16 | test_that("theme_wsj raises error with invalid palette", { 17 | expect_error(wsj_pal("asdgasa"), regexp = "valid palette") 18 | }) 19 | 20 | test_that("scale_colour_wsj works", { 21 | expect_s3_class(scale_colour_wsj(), "ScaleDiscrete") 22 | }) 23 | 24 | test_that("scale_fill_wsj works", { 25 | expect_s3_class(scale_fill_wsj(), "ScaleDiscrete") 26 | }) 27 | --------------------------------------------------------------------------------