├── air.toml
├── .github
├── .gitignore
├── FUNDING.yml
└── workflows
│ └── pkgdown.yaml
├── vignettes
├── .gitignore
└── man
│ └── figures
│ ├── README-unnamed-chunk-10-1.png
│ ├── README-unnamed-chunk-11-1.png
│ ├── README-unnamed-chunk-12-1.png
│ ├── README-unnamed-chunk-13-1.png
│ ├── README-unnamed-chunk-16-1.png
│ ├── README-unnamed-chunk-17-1.png
│ ├── README-unnamed-chunk-2-1.png
│ ├── README-unnamed-chunk-3-1.png
│ ├── README-unnamed-chunk-4-1.png
│ ├── README-unnamed-chunk-5-1.png
│ ├── README-unnamed-chunk-6-1.png
│ ├── README-unnamed-chunk-7-1.png
│ ├── README-unnamed-chunk-8-1.png
│ └── README-unnamed-chunk-9-1.png
├── LICENSE
├── man
├── figures
│ ├── logo.png
│ └── README-unnamed-chunk-2-1.png
├── blue.Rd
├── grey.Rd
├── jumble.Rd
├── lightness.Rd
├── annotate_axis_line.Rd
├── ggblanket-package.Rd
├── label_every_nth.Rd
├── guides_shape_grey.Rd
├── aes_contrast.Rd
├── bind_each_all.Rd
├── scale_x_symmetric.Rd
├── scale_y_symmetric.Rd
├── set_blanket.Rd
├── flex_mode_base.Rd
├── flex_mode_t.Rd
├── flex_mode_r.Rd
└── flex_mode_b.Rd
├── .vscode
├── extensions.json
└── settings.json
├── pkgdown
└── favicon
│ ├── favicon.ico
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── favicon-96x96.png
│ ├── apple-touch-icon.png
│ ├── apple-touch-icon-60x60.png
│ ├── apple-touch-icon-76x76.png
│ ├── apple-touch-icon-120x120.png
│ ├── apple-touch-icon-152x152.png
│ ├── apple-touch-icon-180x180.png
│ ├── web-app-manifest-192x192.png
│ ├── web-app-manifest-512x512.png
│ └── site.webmanifest
├── .gitignore
├── tests
├── spelling.R
├── testthat.R
└── testthat
│ ├── test-symmetric.R
│ ├── test-labelled.R
│ ├── test-numeric-col.R
│ ├── test-datetime.R
│ ├── test-modes.R
│ ├── test-positional_scales.R
│ ├── test-ggproto-etc.R
│ ├── test-set_blanket.R
│ └── test-col_palette.R
├── .Rbuildignore
├── R
├── ggblanket-package.R
├── mode_defaults.R
├── colour.R
├── label_every_nth.R
├── guides.R
├── aes.R
├── bind_each_all.R
├── set.R
├── gg_hex.R
├── gg_bar.R
├── gg_area.R
├── gg_bin_2d.R
├── gg_raster.R
├── gg_contour.R
├── gg_freqpoly.R
├── gg_rug.R
├── gg_sf.R
├── gg_line.R
├── gg_point.R
├── gg_histogram.R
├── gg_density.R
├── gg_qq.R
├── gg_violin.R
├── gg_function.R
├── gg_boxplot.R
├── gg_step.R
├── gg_contour_filled.R
├── gg_density_2d.R
├── gg_quantile.R
├── gg_segment.R
├── standardise_width.R
└── gg_tile.R
├── ggblanket.Rproj
├── inst
└── WORDLIST
├── _pkgdown.yml
├── LICENSE.md
├── DESCRIPTION
├── NAMESPACE
├── README.md
└── README.Rmd
/air.toml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.github/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 |
--------------------------------------------------------------------------------
/vignettes/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.R
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | buy_me_a_coffee: davidhodge931
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | YEAR: 2022
2 | COPYRIGHT HOLDER: David Hodge
3 |
--------------------------------------------------------------------------------
/man/figures/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/man/figures/logo.png
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "Posit.air-vscode"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/favicon.ico
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/favicon-16x16.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/favicon-32x32.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-96x96.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/favicon-96x96.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/apple-touch-icon.png
--------------------------------------------------------------------------------
/man/figures/README-unnamed-chunk-2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/man/figures/README-unnamed-chunk-2-1.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | .Rdata
4 | .httr-oauth
5 | .DS_Store
6 | docs
7 | inst/doc
8 | /doc/
9 | /Meta/
10 | revdep/
11 |
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/pkgdown/favicon/web-app-manifest-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/web-app-manifest-192x192.png
--------------------------------------------------------------------------------
/pkgdown/favicon/web-app-manifest-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/pkgdown/favicon/web-app-manifest-512x512.png
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "[r]": {
3 | "editor.formatOnSave": true,
4 | "editor.defaultFormatter": "Posit.air-vscode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-10-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-10-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-11-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-11-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-12-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-12-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-13-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-13-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-16-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-16-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-17-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-17-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-2-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-3-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-3-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-4-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-4-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-5-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-5-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-6-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-6-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-7-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-7-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-8-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-8-1.png
--------------------------------------------------------------------------------
/vignettes/man/figures/README-unnamed-chunk-9-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/davidhodge931/ggblanket/HEAD/vignettes/man/figures/README-unnamed-chunk-9-1.png
--------------------------------------------------------------------------------
/tests/spelling.R:
--------------------------------------------------------------------------------
1 | if (requireNamespace('spelling', quietly = TRUE)) {
2 | spelling::spell_check_test(
3 | vignettes = TRUE,
4 | error = FALSE,
5 | skip_on_cran = TRUE
6 | )
7 | }
8 |
--------------------------------------------------------------------------------
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^.*\.Rproj$
2 | ^\.Rproj\.user$
3 | ^LICENSE\.md$
4 | ^README\.Rmd$
5 | ^_pkgdown\.yml$
6 | ^docs$
7 | ^pkgdown$
8 | ^\.github$
9 | ^doc$
10 | ^Meta$
11 | ^vignettes/articles$
12 | ^[\.]?air\.toml$
13 | ^\.vscode$
14 |
--------------------------------------------------------------------------------
/R/ggblanket-package.R:
--------------------------------------------------------------------------------
1 | #' @keywords internal
2 | "_PACKAGE"
3 |
4 | ## usethis namespace: start
5 |
6 | #' @importFrom rlang !!
7 | #' @importFrom rlang !!!
8 | #' @importFrom rlang .data
9 | #' @importFrom rlang :=
10 |
11 | utils::globalVariables(c(".x"))
12 | ## usethis namespace: end
13 | NULL
14 |
--------------------------------------------------------------------------------
/man/blue.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/colour.R
3 | \docType{data}
4 | \name{blue}
5 | \alias{blue}
6 | \title{A blue colour}
7 | \usage{
8 | blue
9 | }
10 | \value{
11 | A character vector.
12 | }
13 | \description{
14 | A blue colour.
15 | }
16 | \examples{
17 | scales::show_col(blue)
18 | }
19 | \keyword{datasets}
20 |
--------------------------------------------------------------------------------
/man/grey.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/colour.R
3 | \docType{data}
4 | \name{grey}
5 | \alias{grey}
6 | \title{A grey colour}
7 | \usage{
8 | grey
9 | }
10 | \value{
11 | A character vector.
12 | }
13 | \description{
14 | A grey colour.
15 | }
16 | \examples{
17 | scales::show_col(grey)
18 | }
19 | \keyword{datasets}
20 |
--------------------------------------------------------------------------------
/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(ggblanket)
11 |
12 | test_check("ggblanket")
13 |
--------------------------------------------------------------------------------
/ggblanket.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 | ProjectId: 92154885-2d6e-48d1-98ea-2ca5dc3023b3
3 |
4 | RestoreWorkspace: Default
5 | SaveWorkspace: Default
6 | AlwaysSaveHistory: Default
7 |
8 | EnableCodeIndexing: Yes
9 | UseSpacesForTab: Yes
10 | NumSpacesForTab: 2
11 | Encoding: UTF-8
12 |
13 | RnwWeave: Sweave
14 | LaTeX: pdfLaTeX
15 |
16 | AutoAppendNewline: Yes
17 | StripTrailingWhitespace: Yes
18 |
19 | BuildType: Package
20 | PackageUseDevtools: Yes
21 | PackageInstallArgs: --no-multiarch --with-keep.source
22 |
--------------------------------------------------------------------------------
/pkgdown/favicon/site.webmanifest:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "short_name": "",
4 | "icons": [
5 | {
6 | "src": "/web-app-manifest-192x192.png",
7 | "sizes": "192x192",
8 | "type": "image/png",
9 | "purpose": "maskable"
10 | },
11 | {
12 | "src": "/web-app-manifest-512x512.png",
13 | "sizes": "512x512",
14 | "type": "image/png",
15 | "purpose": "maskable"
16 | }
17 | ],
18 | "theme_color": "#ffffff",
19 | "background_color": "#ffffff",
20 | "display": "standalone"
21 | }
--------------------------------------------------------------------------------
/man/jumble.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/colour.R
3 | \docType{data}
4 | \name{jumble}
5 | \alias{jumble}
6 | \alias{teal}
7 | \alias{orange}
8 | \alias{navy}
9 | \alias{red}
10 | \alias{pink}
11 | \alias{purple}
12 | \title{The jumble palette}
13 | \usage{
14 | jumble
15 |
16 | teal
17 |
18 | orange
19 |
20 | navy
21 |
22 | red
23 |
24 | pink
25 |
26 | purple
27 | }
28 | \value{
29 | A character vector.
30 | }
31 | \description{
32 | A discrete palette that is relatively colour-blind safe.
33 | }
34 | \examples{
35 | colorspace::swatchplot(c(jumble, grey), cvd = TRUE)
36 | }
37 | \keyword{datasets}
38 |
--------------------------------------------------------------------------------
/inst/WORDLIST:
--------------------------------------------------------------------------------
1 | Coord
2 | Errorbar
3 | Freqpoly
4 | Inf
5 | Linerange
6 | Nik
7 | ORCID
8 | Pointrange
9 | Qq
10 | RStudio
11 | Rect
12 | Stat
13 | abline
14 | beeswarm
15 | coord
16 | dplyr
17 | errorbar
18 | etc
19 | freqpoly
20 | geoms
21 | gg
22 | ggbeeswarm
23 | ggblend
24 | ggdensity
25 | ggdist
26 | ggeasy
27 | ggforce
28 | ggh
29 | gghighlight
30 | ggpattern
31 | ggplot
32 | ggproto
33 | ggrepel
34 | ggridges
35 | gridline
36 | gridlines
37 | hline
38 | linerange
39 | linetype
40 | linewidth
41 | linewidths
42 | nd
43 | paletteer
44 | pointrange
45 | qq
46 | rect
47 | ridgeline
48 | showtext
49 | snakecase
50 | stat
51 | tibble
52 | tidyverse
53 | vjust
54 | vline
55 |
--------------------------------------------------------------------------------
/R/mode_defaults.R:
--------------------------------------------------------------------------------
1 | #' Mode colour and linewidth defaults
2 | #'
3 | #' @description
4 | #' `lightness` and `darkness` are vectors of 3 colours used in the `*_theme_*` themes for the for the text, axis.line (and axis.ticks), panel.grid, panel.background and plot.background etc.
5 | #'
6 | #' `linewidthness` is a vector of 2 integers used in the `*_theme_*` themes for the linewidth of the axis.line (axis.ticks and legend.ticks) and panel.grid theme elements.
7 | #'
8 | #' @format NULL
9 | #' @return A character vector.
10 | #' @export
11 | #'
12 | #' @examples
13 | #' scales::show_col(c(lightness, darkness), ncol = 3)
14 | lightness <- c("#121B24FF", "#F6F8FAFF", "#FFFFFFFF")
15 |
16 | #' @rdname lightness
17 | #' @format NULL
18 | #' @export
19 | darkness <- c("#C8D7DFFF", "#00040AFF", "#050D1BFF")
20 |
--------------------------------------------------------------------------------
/tests/testthat/test-symmetric.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(palmerpenguins)
5 | library(ggplot2)
6 |
7 | set_blanket()
8 |
9 | test_name <- "1"
10 |
11 | test_that(test_name, {
12 | p <- penguins |>
13 | gg_histogram(
14 | y = flipper_length_mm,
15 | x_symmetric = FALSE,
16 | y_symmetric = TRUE,
17 | mode_orientation = NULL,
18 | )
19 |
20 | vdiffr::expect_doppelganger(test_name, p)
21 | })
22 |
23 | test_name <- "2"
24 |
25 | test_that(test_name, {
26 | p <- penguins |>
27 | gg_histogram(
28 | y = flipper_length_mm,
29 | x_symmetric = TRUE,
30 | y_symmetric = FALSE,
31 | )
32 |
33 | vdiffr::expect_doppelganger(test_name, p)
34 | })
35 |
--------------------------------------------------------------------------------
/man/lightness.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/mode_defaults.R
3 | \docType{data}
4 | \name{lightness}
5 | \alias{lightness}
6 | \alias{darkness}
7 | \title{Mode colour and linewidth defaults}
8 | \usage{
9 | lightness
10 |
11 | darkness
12 | }
13 | \value{
14 | A character vector.
15 | }
16 | \description{
17 | \code{lightness} and \code{darkness} are vectors of 3 colours used in the \verb{*_theme_*} themes for the for the text, axis.line (and axis.ticks), panel.grid, panel.background and plot.background etc.
18 |
19 | \code{linewidthness} is a vector of 2 integers used in the \verb{*_theme_*} themes for the linewidth of the axis.line (axis.ticks and legend.ticks) and panel.grid theme elements.
20 | }
21 | \examples{
22 | scales::show_col(c(lightness, darkness), ncol = 3)
23 | }
24 | \keyword{datasets}
25 |
--------------------------------------------------------------------------------
/man/annotate_axis_line.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/annotate_axis.R
3 | \name{annotate_axis_line}
4 | \alias{annotate_axis_line}
5 | \title{Annotated axis line segment}
6 | \usage{
7 | annotate_axis_line(position, ..., colour = NULL, linewidth = NULL)
8 | }
9 | \arguments{
10 | \item{position}{The position of the axis. One of "bottom", "top", "left", or "right".}
11 |
12 | \item{...}{Extra parameters passed to \code{ggplot2::annotate("segment", ...)}.}
13 |
14 | \item{colour}{The colour of the annotated segment. Inherits from the current theme axis.line etc.}
15 |
16 | \item{linewidth}{The linewidth of the annotated segment. Inherits from the current theme axis.line etc.}
17 | }
18 | \value{
19 | A list of a annotate layer and theme elements.
20 | }
21 | \description{
22 | Replace axis line with an annotated segment.
23 | }
24 |
--------------------------------------------------------------------------------
/_pkgdown.yml:
--------------------------------------------------------------------------------
1 | url: https://davidhodge931.github.io/ggblanket/
2 | template:
3 | bootstrap: 5
4 | light-switch: true
5 | reference:
6 | - title: Set
7 | - contents:
8 | - set_blanket
9 | - title: Wrap
10 | - contents:
11 | - gg_blanket
12 | - starts_with("gg_")
13 | - title: Theme
14 | - contents:
15 | - light_mode_r
16 | - light_mode_t
17 | - light_mode_b
18 | - dark_mode_r
19 | - dark_mode_t
20 | - dark_mode_b
21 | - title: Palette
22 | - contents:
23 | - blue
24 | - jumble
25 | - teal
26 | - orange
27 | - navy
28 | - red
29 | - pink
30 | - purple
31 | - grey
32 | - lightness
33 | - darkness
34 | - title: Extra
35 | - contents:
36 | - aes_contrast
37 | - annotate_axis_line
38 | - bind_each_all
39 | - guides_shape_grey
40 | - guides_linewidth_grey
41 | - guides_size_grey
42 | - label_every_nth
43 | - scale_x_symmetric
44 | - scale_y_symmetric
45 |
46 |
--------------------------------------------------------------------------------
/man/ggblanket-package.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/ggblanket-package.R
3 | \docType{package}
4 | \name{ggblanket-package}
5 | \alias{ggblanket}
6 | \alias{ggblanket-package}
7 | \title{ggblanket: Simplify 'ggplot2' Visualisation}
8 | \description{
9 | \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}}
10 |
11 | Simplify 'ggplot2' visualisation with 'ggblanket' wrapper functions.
12 | }
13 | \seealso{
14 | Useful links:
15 | \itemize{
16 | \item \url{https://davidhodge931.github.io/ggblanket/}
17 | \item \url{https://github.com/davidhodge931/ggblanket}
18 | \item Report bugs at \url{https://github.com/davidhodge931/ggblanket/issues}
19 | }
20 |
21 | }
22 | \author{
23 | \strong{Maintainer}: David Hodge \email{davidhodge931@gmail.com} (\href{https://orcid.org/0000-0002-3868-7501}{ORCID}) [copyright holder]
24 |
25 | }
26 | \keyword{internal}
27 |
--------------------------------------------------------------------------------
/tests/testthat/test-labelled.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(ggplot2)
5 | library(dplyr)
6 | library(stringr)
7 | library(tidyr)
8 | library(palmerpenguins)
9 | set_blanket()
10 |
11 | ## ---------------------------------------------------------------------------------------------------
12 | test_name <- "labelled"
13 |
14 | test_that(test_name, {
15 | p <- tibble::tibble(
16 | q1 = c("M", "F"),
17 | q2 = c(TRUE, FALSE),
18 | q3 = c(1, 2),
19 | q4 = factor(c(1, 2)),
20 | ) |>
21 | labelled::set_variable_labels(
22 | q1 = "Sex",
23 | q2 = "Happy",
24 | q3 = "Age",
25 | q4 = "Zero or one"
26 | ) |> #str()
27 | gg_point(
28 | x = q2,
29 | y = q1,
30 | col = q3,
31 | facet = q4,
32 | )
33 |
34 | vdiffr::expect_doppelganger(test_name, p)
35 | })
36 |
37 | set_blanket()
38 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | # MIT License
2 |
3 | Copyright (c) 2022 David Hodge
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/man/label_every_nth.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/label_every_nth.R
3 | \name{label_every_nth}
4 | \alias{label_every_nth}
5 | \title{Label every nth element}
6 | \usage{
7 | label_every_nth(n = 2, offset = 0, ...)
8 | }
9 | \arguments{
10 | \item{n}{The increment of elements to hold as is. Defaults to \code{2}.}
11 |
12 | \item{offset}{An offset for which element to first hold. Defaults to \code{0}. Possible values are \code{-1} to (\code{n - 2})}
13 |
14 | \item{...}{If numeric, arguments passed to the \code{scales::comma} function. Otherwise, arguments passed to \code{format}.}
15 | }
16 | \value{
17 | A labelling function
18 | }
19 | \description{
20 | Label every nth element in a vector, and replace the rest with "".
21 | }
22 | \examples{
23 | label_every_nth()(scales::comma(seq(1000, 5000, 1000)))
24 | label_every_nth()(lubridate::ymd(c("2021-01-01", "2022-01-01", "2023-01-01", "2024-01-01")))
25 | label_every_nth()(LETTERS[1:12])
26 |
27 | library(dplyr)
28 | library(palmerpenguins)
29 |
30 | set_blanket()
31 |
32 | penguins |>
33 | mutate(across(sex, \(x) stringr::str_to_sentence(x))) |>
34 | gg_point(
35 | x = flipper_length_mm,
36 | y = body_mass_g,
37 | col = sex,
38 | x_labels = label_every_nth(),
39 | y_labels = label_every_nth(),
40 | )
41 | }
42 |
--------------------------------------------------------------------------------
/man/guides_shape_grey.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/guides.R
3 | \name{guides_shape_grey}
4 | \alias{guides_shape_grey}
5 | \alias{guides_linewidth_grey}
6 | \alias{guides_size_grey}
7 | \title{Guides for legend element colour}
8 | \usage{
9 | guides_shape_grey(colour = grey, ...)
10 |
11 | guides_linewidth_grey(colour = grey, ...)
12 |
13 | guides_size_grey(colour = grey, ...)
14 | }
15 | \arguments{
16 | \item{colour}{A default hex code to override the colour of the legend elements. Note, the "fill" inherits from this argument. Defaults to grey.}
17 |
18 | \item{...}{Other arguments passed to \code{\link[ggplot2:guide_legend]{ggplot2::guide_legend()}}.}
19 | }
20 | \value{
21 | A ggplot guides.
22 | }
23 | \description{
24 | Guides to over-ride legend elements with a grey colour
25 | \itemize{
26 | \item \code{guides_shape_grey()} for shape
27 | \item \code{guides_linewidth_grey()} for linewidth
28 | \item \code{guides_size_grey()} for size.
29 | }
30 | }
31 | \examples{
32 | library(dplyr)
33 | library(tidyr)
34 | library(ggplot2)
35 | library(palmerpenguins)
36 |
37 | set_blanket()
38 |
39 | penguins |>
40 | drop_na() |>
41 | gg_jitter(
42 | x = species,
43 | y = flipper_length_mm,
44 | col = island,
45 | mapping = aes(shape = sex),
46 | ) +
47 | guides_shape_grey()
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/R/colour.R:
--------------------------------------------------------------------------------
1 | #' A blue colour
2 | #'
3 | #' @description A blue colour.
4 | #'
5 | #' @format NULL
6 | #' @return A character vector.
7 | #' @export
8 | #'
9 | #' @examples
10 | #' scales::show_col(blue)
11 | blue <- "#357BA2FF"
12 |
13 |
14 | #' A grey colour
15 | #'
16 | #' @description A grey colour.
17 | #'
18 | #' @format NULL
19 | #' @return A character vector.
20 | #' @export
21 | #'
22 | #' @examples
23 | #' scales::show_col(grey)
24 | grey <- "#CDC5BFFF"
25 |
26 | #' The jumble palette
27 | #'
28 | #' @description
29 | #' A discrete palette that is relatively colour-blind safe.
30 | #'
31 | #' @format NULL
32 | #' @return A character vector.
33 | #' @export
34 | #'
35 | #' @examples
36 | #' colorspace::swatchplot(c(jumble, grey), cvd = TRUE)
37 | jumble <- c(
38 | "#0095A8FF",
39 | "#FFA600FF",
40 | "#003F5CFF",
41 | "#DA3C39FF",
42 | "#EC9ECBFF",
43 | "#67609CFF"
44 | )
45 |
46 | #' @rdname jumble
47 | #' @format NULL
48 | #' @export
49 | teal <- "#0095A8FF"
50 |
51 | #' @rdname jumble
52 | #' @format NULL
53 | #' @export
54 | orange <- "#FFA600FF"
55 |
56 | #' @rdname jumble
57 | #' @format NULL
58 | #' @export
59 | navy <- "#003F5CFF"
60 |
61 | #' @rdname jumble
62 | #' @format NULL
63 | #' @export
64 | red <- "#DA3C39FF"
65 |
66 | #' @rdname jumble
67 | #' @format NULL
68 | #' @export
69 | pink <- "#EC9ECBFF"
70 |
71 | #' @rdname jumble
72 | #' @format NULL
73 | #' @export
74 | purple <- "#67609CFF"
75 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/R/label_every_nth.R:
--------------------------------------------------------------------------------
1 | #' Label every nth element
2 | #'
3 | #' @description
4 | #' Label every nth element in a vector, and replace the rest with "".
5 | #'
6 | #' @param n The increment of elements to hold as is. Defaults to `2`.
7 | #' @param offset An offset for which element to first hold. Defaults to `0`. Possible values are `-1` to (`n - 2`)
8 | #' @param ... If numeric, arguments passed to the `scales::comma` function. Otherwise, arguments passed to `format`.
9 | #'
10 | #' @return A labelling function
11 | #' @export
12 | #'
13 | #' @examples
14 | #' label_every_nth()(scales::comma(seq(1000, 5000, 1000)))
15 | #' label_every_nth()(lubridate::ymd(c("2021-01-01", "2022-01-01", "2023-01-01", "2024-01-01")))
16 | #' label_every_nth()(LETTERS[1:12])
17 | #'
18 | #' library(dplyr)
19 | #' library(palmerpenguins)
20 | #'
21 | #' set_blanket()
22 | #'
23 | #' penguins |>
24 | #' mutate(across(sex, \(x) stringr::str_to_sentence(x))) |>
25 | #' gg_point(
26 | #' x = flipper_length_mm,
27 | #' y = body_mass_g,
28 | #' col = sex,
29 | #' x_labels = label_every_nth(),
30 | #' y_labels = label_every_nth(),
31 | #' )
32 | #
33 | label_every_nth <- function(n = 2, offset = 0, ...) {
34 | function(x) {
35 | i <- which(is.finite(x) | is.character(x) | is.factor(x) | is.logical(x))
36 | i <- i[seq_along(i) %% n == (offset + 1)]
37 |
38 | if (is.numeric(x)) {
39 | x <- scales::comma(x, ...)
40 | } else {
41 | x <- format(x, ...)
42 | }
43 |
44 | x[-i] <- ""
45 | x
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/tests/testthat/test-numeric-col.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(palmerpenguins)
5 | library(ggplot2)
6 | set_blanket(colour = "#121b24")
7 |
8 | test_name <- "light_mode_r"
9 |
10 | test_that(test_name, {
11 | set.seed(123)
12 |
13 | p <- penguins |>
14 | gg_point(
15 | x = flipper_length_mm,
16 | y = island,
17 | col = bill_depth_mm,
18 | facet = sex,
19 | mapping = aes(alpha = species, shape = species),
20 | theme = light_mode_r()
21 | ) +
22 | scale_alpha_manual(values = c(1, 1, 0.33))
23 |
24 | vdiffr::expect_doppelganger(test_name, p)
25 | })
26 |
27 | test_name <- "light_mode_t"
28 |
29 | test_that(test_name, {
30 | set.seed(123)
31 |
32 | p <- penguins |>
33 | gg_point(
34 | x = flipper_length_mm,
35 | y = island,
36 | col = bill_depth_mm,
37 | facet = sex,
38 | mapping = aes(alpha = species, shape = species),
39 | theme = light_mode_t()
40 | ) +
41 | scale_alpha_manual(values = c(1, 1, 0.33))
42 |
43 | vdiffr::expect_doppelganger(test_name, p)
44 | })
45 |
46 | test_name <- "light_mode_b"
47 |
48 | test_that(test_name, {
49 | set.seed(123)
50 |
51 | p <- penguins |>
52 | gg_point(
53 | x = flipper_length_mm,
54 | y = island,
55 | col = bill_depth_mm,
56 | facet = sex,
57 | mapping = aes(alpha = species, shape = species),
58 | theme = light_mode_b()
59 | ) +
60 | scale_alpha_manual(values = c(1, 1, 0.33))
61 |
62 | vdiffr::expect_doppelganger(test_name, p)
63 | })
64 |
65 | set_blanket()
66 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: ggblanket
2 | Title: Simplify 'ggplot2' Visualisation
3 | Version: 12.4.0900
4 | Authors@R:
5 | person("David", "Hodge", , "davidhodge931@gmail.com", role = c("aut", "cre", "cph"),
6 | comment = c(ORCID = "0000-0002-3868-7501"))
7 | Description: Simplify 'ggplot2' visualisation with 'ggblanket' wrapper
8 | functions.
9 | License: MIT + file LICENSE
10 | URL: https://davidhodge931.github.io/ggblanket/,
11 | https://github.com/davidhodge931/ggblanket
12 | BugReports: https://github.com/davidhodge931/ggblanket/issues
13 | Depends:
14 | R (>= 4.2.0)
15 | Imports:
16 | colorspace,
17 | dplyr (>= 1.0.4),
18 | farver,
19 | forcats,
20 | ggblend,
21 | ggplot2 (>= 3.5.2),
22 | grid,
23 | hms (>= 0.5.0),
24 | labelled,
25 | lubridate (>= 1.7.8),
26 | purrr,
27 | rlang (>= 1.1.0),
28 | scales (>= 1.4.0),
29 | snakecase,
30 | stringr (>= 1.3.0),
31 | tidyr (>= 1.0.0),
32 | tidyselect (>= 1.2.0),
33 | viridisLite
34 | Suggests:
35 | spelling,
36 | hexbin,
37 | isoband,
38 | knitr,
39 | palmerpenguins,
40 | patchwork,
41 | quantreg,
42 | rmarkdown,
43 | sf,
44 | testthat (>= 3.0.0),
45 | tibble,
46 | vdiffr,
47 | viridis
48 | VignetteBuilder:
49 | knitr
50 | Config/Needs/website: concaveman, corrr, farver, ggbeeswarm, ggblend, ggdensity,
51 | ggdist, ggeasy, ggforce, ggh4x, gghighlight, ggnewscale, ggrepel, ggridges,
52 | ggpattern, glue, marquee, paletteer, showtext, sysfonts
53 | Config/testthat/edition: 3
54 | Encoding: UTF-8
55 | Language: en-GB
56 | Roxygen: list(markdown = TRUE)
57 | RoxygenNote: 7.3.2
58 |
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | # Generated by roxygen2: do not edit by hand
2 |
3 | export(aes_contrast)
4 | export(annotate_axis_line)
5 | export(bind_each_all)
6 | export(blue)
7 | export(dark_mode_b)
8 | export(dark_mode_r)
9 | export(dark_mode_t)
10 | export(darkness)
11 | export(gg_area)
12 | export(gg_bar)
13 | export(gg_bin_2d)
14 | export(gg_blanket)
15 | export(gg_boxplot)
16 | export(gg_col)
17 | export(gg_contour)
18 | export(gg_contour_filled)
19 | export(gg_crossbar)
20 | export(gg_density)
21 | export(gg_density_2d)
22 | export(gg_density_2d_filled)
23 | export(gg_errorbar)
24 | export(gg_freqpoly)
25 | export(gg_function)
26 | export(gg_hex)
27 | export(gg_histogram)
28 | export(gg_jitter)
29 | export(gg_label)
30 | export(gg_line)
31 | export(gg_linerange)
32 | export(gg_path)
33 | export(gg_point)
34 | export(gg_pointrange)
35 | export(gg_polygon)
36 | export(gg_qq)
37 | export(gg_quantile)
38 | export(gg_raster)
39 | export(gg_rect)
40 | export(gg_ribbon)
41 | export(gg_rug)
42 | export(gg_segment)
43 | export(gg_sf)
44 | export(gg_smooth)
45 | export(gg_step)
46 | export(gg_text)
47 | export(gg_tile)
48 | export(gg_violin)
49 | export(grey)
50 | export(guides_linewidth_grey)
51 | export(guides_shape_grey)
52 | export(guides_size_grey)
53 | export(jumble)
54 | export(label_every_nth)
55 | export(light_mode_b)
56 | export(light_mode_r)
57 | export(light_mode_t)
58 | export(lightness)
59 | export(navy)
60 | export(orange)
61 | export(pink)
62 | export(purple)
63 | export(red)
64 | export(scale_x_symmetric)
65 | export(scale_y_symmetric)
66 | export(set_blanket)
67 | export(teal)
68 | importFrom(rlang,"!!!")
69 | importFrom(rlang,"!!")
70 | importFrom(rlang,":=")
71 | importFrom(rlang,.data)
72 |
--------------------------------------------------------------------------------
/R/guides.R:
--------------------------------------------------------------------------------
1 | #' Guides for legend element colour
2 | #'
3 | #' @description
4 | #' Guides to over-ride legend elements with a grey colour
5 | #' * `guides_shape_grey()` for shape
6 | #' * `guides_linewidth_grey()` for linewidth
7 | #' * `guides_size_grey()` for size.
8 | #'
9 | #' @param colour A default hex code to override the colour of the legend elements. Note, the "fill" inherits from this argument. Defaults to grey.
10 | #' @param ... Other arguments passed to [ggplot2::guide_legend()].
11 | #'
12 | #' @return A ggplot guides.
13 | #' @export
14 | #'
15 | #' @examples
16 | #' library(dplyr)
17 | #' library(tidyr)
18 | #' library(ggplot2)
19 | #' library(palmerpenguins)
20 | #'
21 | #' set_blanket()
22 | #'
23 | #' penguins |>
24 | #' drop_na() |>
25 | #' gg_jitter(
26 | #' x = species,
27 | #' y = flipper_length_mm,
28 | #' col = island,
29 | #' mapping = aes(shape = sex),
30 | #' ) +
31 | #' guides_shape_grey()
32 | #'
33 | guides_shape_grey <- function(colour = grey, ...) {
34 | ggplot2::guides(
35 | shape = ggplot2::guide_legend(
36 | override.aes = list(colour = colour, fill = colour),
37 | ...
38 | )
39 | )
40 | }
41 |
42 | #' @rdname guides_shape_grey
43 | #' @export
44 | guides_linewidth_grey <- function(colour = grey, ...) {
45 | ggplot2::guides(
46 | linewidth = ggplot2::guide_legend(
47 | override.aes = list(colour = colour, fill = colour),
48 | ...
49 | )
50 | )
51 | }
52 |
53 | #' @rdname guides_shape_grey
54 | #' @export
55 | guides_size_grey <- function(colour = grey, ...) {
56 | ggplot2::guides(
57 | size = ggplot2::guide_legend(
58 | override.aes = list(colour = colour, fill = colour),
59 | ...
60 | )
61 | )
62 | }
63 |
--------------------------------------------------------------------------------
/man/aes_contrast.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/aes.R
3 | \name{aes_contrast}
4 | \alias{aes_contrast}
5 | \title{A colour aesthetic for contrast}
6 | \usage{
7 | aes_contrast(..., dark = "#121B24FF", light = "#FFFFFFFF")
8 | }
9 | \arguments{
10 | \item{...}{Provided to require argument naming, support trailing commas etc.}
11 |
12 | \item{dark}{A dark colour.}
13 |
14 | \item{light}{A light colour.}
15 | }
16 | \value{
17 | A ggplot2 aesthetic
18 | }
19 | \description{
20 | A colour aesthetic to contrast with a fill aesthetic. Can be spliced into \link[ggplot2:aes]{ggplot2::aes} with \link[rlang:splice-operator]{rlang::!!!}.
21 | }
22 | \examples{
23 | library(ggplot2)
24 | library(dplyr)
25 | library(stringr)
26 | library(palmerpenguins)
27 |
28 | set_blanket()
29 |
30 | penguins |>
31 | count(species, sex) |>
32 | gg_col(
33 | x = sex,
34 | y = n,
35 | col = species,
36 | label = n,
37 | position = position_dodge(preserve = "single"),
38 | width = 0.75,
39 | x_labels = \(x) str_to_sentence(x),
40 | ) +
41 | geom_text(
42 | mapping = aes_contrast(),
43 | position = position_dodge(width = 0.75, preserve = "single"),
44 | vjust = 1.33,
45 | show.legend = FALSE,
46 | )
47 |
48 | penguins |>
49 | count(species, sex) |>
50 | gg_col(
51 | x = sex,
52 | y = n,
53 | col = species,
54 | position = position_dodge(preserve = "single"),
55 | width = 0.75,
56 | x_labels = \(x) str_to_sentence(x),
57 | theme = dark_mode_r(),
58 | ) +
59 | geom_text(
60 | mapping = aes(label = n, !!!aes_contrast(dark = darkness[3], light = darkness[1])),
61 | position = position_dodge(width = 0.75, preserve = "single"),
62 | vjust = 1.33,
63 | show.legend = FALSE,
64 | )
65 | }
66 |
--------------------------------------------------------------------------------
/tests/testthat/test-datetime.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(ggplot2)
5 | library(dplyr)
6 |
7 | set_blanket()
8 |
9 | set.seed(123)
10 | t <- as.POSIXct("2021-01-01")
11 | e1 <- as.POSIXct("2021-12-31 23:59:59")
12 | n1 <- as.numeric(lubridate::as.duration(e1 - t))
13 | s1 <- sample(seq.int(n1), 3000L)
14 |
15 | ## ---------------------------------------------------------------------------------------------------
16 | test_name <- "datetime"
17 |
18 | test_that(test_name, {
19 | p <- tibble::tibble(dttm = t + s1) |>
20 | dplyr::mutate(mon = lubridate::floor_date(dttm, "month")) |>
21 | dplyr::summarise(total = dplyr::n(), .by = "mon") |>
22 | gg_point(
23 | x = mon,
24 | y = total,
25 | )
26 |
27 | vdiffr::expect_doppelganger(test_name, p)
28 | })
29 |
30 | ## ---------------------------------------------------------------------------------------------------
31 | test_name <- "time"
32 |
33 | test_that(test_name, {
34 | p <- tibble::tibble(dttm = t + s1) |>
35 | dplyr::mutate(mon = lubridate::floor_date(dttm, "month")) |>
36 | dplyr::summarise(total = dplyr::n(), .by = "mon") |>
37 | dplyr::mutate(mon = hms::as_hms(mon)) |>
38 | gg_point(
39 | x = mon,
40 | y = total,
41 | )
42 |
43 | vdiffr::expect_doppelganger(test_name, p)
44 | })
45 |
46 | ## ---------------------------------------------------------------------------------------------------
47 | test_name <- "date"
48 |
49 | test_that(test_name, {
50 | p <- tibble::tibble(dttm = t + s1) |>
51 | dplyr::mutate(mon = lubridate::floor_date(dttm, "month")) |>
52 | dplyr::summarise(total = dplyr::n(), .by = "mon") |>
53 | dplyr::mutate(mon = lubridate::as_date(mon)) |>
54 | gg_point(
55 | x = mon,
56 | y = total,
57 | )
58 |
59 | vdiffr::expect_doppelganger(test_name, p)
60 | })
61 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # ggblanket
5 |
6 |
7 |
8 | [](https://CRAN.R-project.org/package=ggblanket)
10 | [](https://r-pkg.org/pkg/ggblanket)
12 | [](https://r-pkg.org/pkg/ggblanket)
14 | [](https://r-pkg.org/pkg/ggblanket)
16 | [](https://r-pkg.org/pkg/ggblanket)
18 |
19 |
20 | ## Overview
21 |
22 | ggblanket is a package of ggplot2 wrapper functions.
23 |
24 | The primary objective is to **simplify ggplot2 visualisation**.
25 |
26 | Secondary objectives relate to:
27 |
28 | - Design: produce well-designed visualisation
29 | - Alignment: align with ggplot2 and tidyverse
30 | - Scope: cover much of what ggplot2 does.
31 |
32 | Computational speed has been traded-off.
33 |
34 | ## Installation
35 |
36 | ``` r
37 | install.packages("ggblanket")
38 | ```
39 |
40 | ## Example
41 |
42 | ``` r
43 | library(ggblanket)
44 | library(palmerpenguins)
45 |
46 | set_blanket()
47 |
48 | penguins |>
49 | gg_histogram(
50 | x = flipper_length_mm,
51 | col = species,
52 | )
53 | ```
54 |
55 |
56 |
57 | ## Get started
58 |
59 | Click
60 | [here](https://davidhodge931.github.io/ggblanket/articles/ggblanket.html)
61 | to start learning how ggblanket works.
62 |
63 | ## Thank you
64 |
65 | Thanks to the developers of ggplot2, tidyverse and the R ecosystem.
66 |
67 | For Dad, always missed (Peter Hodge, 1953-2023).
68 |
--------------------------------------------------------------------------------
/tests/testthat/test-modes.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(palmerpenguins)
5 | library(ggplot2)
6 |
7 | set_blanket()
8 |
9 | test_name <- "light_mode_r"
10 |
11 | test_that(test_name, {
12 | p <- penguins |>
13 | gg_point(
14 | x = flipper_length_mm,
15 | y = body_mass_g,
16 | col = species,
17 | facet = sex,
18 | facet2 = island,
19 | mapping = aes(alpha = species, shape = species),
20 | theme = light_mode_r()
21 | ) +
22 | scale_alpha_manual(values = c(1, 1, 0.33))
23 |
24 | vdiffr::expect_doppelganger(test_name, p)
25 | })
26 |
27 | test_name <- "light_mode_t"
28 |
29 | test_that(test_name, {
30 | p <- penguins |>
31 | gg_point(
32 | x = flipper_length_mm,
33 | y = body_mass_g,
34 | col = species,
35 | facet = sex,
36 | facet2 = island,
37 | mapping = aes(alpha = species, shape = species),
38 | theme = light_mode_t()
39 | ) +
40 | scale_alpha_manual(values = c(1, 1, 0.33))
41 |
42 | vdiffr::expect_doppelganger(test_name, p)
43 | })
44 |
45 | test_name <- "light_mode_b"
46 |
47 | test_that(test_name, {
48 | p <- penguins |>
49 | gg_point(
50 | x = flipper_length_mm,
51 | y = body_mass_g,
52 | col = species,
53 | facet = sex,
54 | facet2 = island,
55 | mapping = aes(alpha = species, shape = species),
56 | theme = light_mode_b()
57 | ) +
58 | scale_alpha_manual(values = c(1, 1, 0.33))
59 |
60 | vdiffr::expect_doppelganger(test_name, p)
61 | })
62 |
63 | ###
64 | test_name <- "dark_mode_r"
65 |
66 | test_that(test_name, {
67 | p <- penguins |>
68 | gg_point(
69 | x = flipper_length_mm,
70 | y = body_mass_g,
71 | col = species,
72 | facet = sex,
73 | facet2 = island,
74 | mapping = aes(alpha = species, shape = species),
75 | theme = dark_mode_r()
76 | ) +
77 | scale_alpha_manual(values = c(1, 1, 0.33))
78 |
79 | vdiffr::expect_doppelganger(test_name, p)
80 | })
81 |
82 | set_blanket()
83 |
--------------------------------------------------------------------------------
/tests/testthat/test-positional_scales.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(ggplot2)
5 | library(dplyr)
6 | set_blanket()
7 |
8 | ## ---------------------------------------------------------------------------------------------------
9 | test_name <- "1"
10 |
11 | test_that(test_name, {
12 | p <- penguins |>
13 | gg_point(
14 | x = flipper_length_mm,
15 | y = body_mass_g,
16 | x_breaks = scales::breaks_width(15),
17 | x_limits_include = 250,
18 | x_labels = scales::label_currency(),
19 | x_expand = c(0.5, 0.5),
20 | x_position = "top",
21 | x_label = "Blah",
22 | caption = ""
23 | )
24 |
25 | vdiffr::expect_doppelganger(test_name, p)
26 | })
27 |
28 | ## ---------------------------------------------------------------------------------------------------
29 | test_name <- "2"
30 |
31 | test_that(test_name, {
32 | p <- penguins |>
33 | gg_point(
34 | x = flipper_length_mm,
35 | y = body_mass_g,
36 | y_breaks = scales::breaks_width(1000),
37 | y_limits_include = 7000,
38 | y_labels = scales::label_currency(),
39 | y_expand = c(0.1, 0.1),
40 | y_position = "right",
41 | y_label = "Blah",
42 | caption = ""
43 | )
44 |
45 | vdiffr::expect_doppelganger(test_name, p)
46 | })
47 |
48 | ## ---------------------------------------------------------------------------------------------------
49 | test_name <- "3"
50 |
51 | test_that(test_name, {
52 | p <- penguins |>
53 | gg_point(
54 | x = flipper_length_mm,
55 | y = body_mass_g,
56 | x_breaks = scales::breaks_width(15),
57 | x_limits_include = 250,
58 | x_labels = scales::label_currency(),
59 | x_expand = c(0.5, 0.5),
60 | x_position = "top",
61 | x_label = "Blah",
62 | y_breaks = scales::breaks_width(1000),
63 | y_limits_include = 7000,
64 | y_labels = scales::label_currency(),
65 | y_expand = c(0.1, 0.1),
66 | y_position = "right",
67 | y_label = "Blah",
68 | caption = ""
69 | )
70 |
71 | vdiffr::expect_doppelganger(test_name, p)
72 | })
73 |
74 | set_blanket()
75 |
--------------------------------------------------------------------------------
/README.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | output: rmarkdown::github_document
3 | ---
4 |
5 |
6 |
7 | ```{r, include = FALSE}
8 | knitr::opts_chunk$set(
9 | collapse = TRUE,
10 | comment = "#>",
11 | fig.path = "man/figures/README-",
12 | message = FALSE,
13 | warning = FALSE,
14 | fig.width = 6,
15 | fig.asp = 0.6,
16 | out.width = "75%",
17 | dpi = 300)
18 | ```
19 |
20 | # ggblanket
21 |
22 |
23 | [](https://CRAN.R-project.org/package=ggblanket)
24 | [](https://r-pkg.org/pkg/ggblanket)
25 | [](https://r-pkg.org/pkg/ggblanket)
26 | [](https://r-pkg.org/pkg/ggblanket)
27 | [](https://r-pkg.org/pkg/ggblanket)
28 |
29 |
30 | ## Overview
31 |
32 | ggblanket is a package of ggplot2 wrapper functions.
33 |
34 | The primary objective is to **simplify ggplot2 visualisation**.
35 |
36 | Secondary objectives relate to:
37 |
38 | * Design: produce well-designed visualisation
39 | * Alignment: align with ggplot2 and tidyverse
40 | * Scope: cover much of what ggplot2 does.
41 |
42 | Computational speed has been traded-off.
43 |
44 | ## Installation
45 |
46 | ``` r
47 | install.packages("ggblanket")
48 | ```
49 | ## Example
50 |
51 | ```{r, fig.asp=0.6}
52 | library(ggblanket)
53 | library(palmerpenguins)
54 |
55 | set_blanket()
56 |
57 | penguins |>
58 | gg_histogram(
59 | x = flipper_length_mm,
60 | col = species,
61 | )
62 | ```
63 |
64 | ## Get started
65 |
66 | Click [here](https://davidhodge931.github.io/ggblanket/articles/ggblanket.html) to start learning how ggblanket works.
67 |
68 | ## Thank you
69 |
70 | Thanks to the developers of ggplot2, tidyverse and the R ecosystem.
71 |
72 | For Dad, always missed (Peter Hodge, 1953-2023).
73 |
--------------------------------------------------------------------------------
/man/bind_each_all.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/bind_each_all.R
3 | \name{bind_each_all}
4 | \alias{bind_each_all}
5 | \title{Bind each all.}
6 | \usage{
7 | bind_each_all(
8 | data,
9 | ...,
10 | name = "each_all",
11 | each = "Each",
12 | all = "All",
13 | all_after = Inf
14 | )
15 | }
16 | \arguments{
17 | \item{data}{A data frame or tibble.}
18 |
19 | \item{...}{An unquoted variable.}
20 |
21 | \item{name}{A variable name. Defaults to \code{each_all}.}
22 |
23 | \item{each}{A string for the each value. Defaults to \code{"Each"}.}
24 |
25 | \item{all}{A string for the all value. Defaults to \code{"All"}.}
26 |
27 | \item{all_after}{A number for where the all value should be placed after. Use \code{0} for first or \code{Inf} for last. Defaults to \code{Inf}.}
28 | }
29 | \value{
30 | A data frame or tibble
31 | }
32 | \description{
33 | Binds data to support plotting each category \emph{and} all combined data.
34 | }
35 | \examples{
36 | library(dplyr)
37 | library(ggplot2)
38 | library(palmerpenguins)
39 |
40 | set_blanket()
41 |
42 | penguins |>
43 | count(species)
44 |
45 | penguins |>
46 | bind_each_all(species) |>
47 | count(species, each_all)
48 |
49 | penguins |>
50 | bind_each_all(species) |>
51 | gg_jitter(
52 | x = species,
53 | y = body_mass_g,
54 | )
55 |
56 | penguins |>
57 | bind_each_all(species) |>
58 | gg_jitter(
59 | x = species,
60 | y = body_mass_g,
61 | col = each_all,
62 | col_palette = c(blue, grey),
63 | ) +
64 | theme(legend.position = "none")
65 |
66 | penguins |>
67 | bind_each_all(species) |>
68 | group_by(species, each_all) |>
69 | summarise(across(body_mass_g, \(x) mean(x, na.rm = TRUE))) |>
70 | gg_col(
71 | x = species,
72 | y = body_mass_g,
73 | col = each_all,
74 | col_palette = c(blue, grey),
75 | width = 0.5,
76 | y_label = "Average body mass g",
77 | ) +
78 | theme(legend.position = "none")
79 |
80 | penguins |>
81 | bind_each_all(species, all = "All\nspecies") |>
82 | gg_jitter(
83 | x = species,
84 | y = body_mass_g,
85 | col = each_all,
86 | col_palette = c(blue, grey),
87 | facet = each_all,
88 | facet_layout = "grid",
89 | facet_scales = "free_x",
90 | facet_space = "free_x",
91 | ) +
92 | theme(legend.position = "none") +
93 | theme(strip.text.x = element_blank()) +
94 | labs(x = NULL)
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/tests/testthat/test-ggproto-etc.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(ggplot2)
5 | library(dplyr)
6 | library(stringr)
7 | library(tidyr)
8 | library(palmerpenguins)
9 | set_blanket()
10 |
11 | ## ---------------------------------------------------------------------------------------------------
12 | test_name <- "default"
13 |
14 | test_that(test_name, {
15 | p <- penguins |>
16 | drop_na(sex) |>
17 | mutate(across(sex, \(x) str_to_sentence(x))) |>
18 | gg_blanket(
19 | geom = "violin",
20 | stat = "ydensity",
21 | position = "dodge",
22 | x = sex,
23 | y = body_mass_g,
24 | col = species,
25 | )
26 |
27 | vdiffr::expect_doppelganger(test_name, p)
28 | })
29 |
30 | test_name <- "GeomViolin"
31 |
32 | test_that(test_name, {
33 | p <- penguins |>
34 | drop_na(sex) |>
35 | mutate(across(sex, \(x) str_to_sentence(x))) |>
36 | gg_blanket(
37 | geom = GeomViolin,
38 | stat = "ydensity",
39 | position = "dodge",
40 | x = sex,
41 | y = body_mass_g,
42 | col = species,
43 | )
44 |
45 | vdiffr::expect_doppelganger(test_name, p)
46 | })
47 |
48 | test_name <- "StatYdensity"
49 |
50 | test_that(test_name, {
51 | p <- penguins |>
52 | drop_na(sex) |>
53 | mutate(across(sex, \(x) str_to_sentence(x))) |>
54 | gg_blanket(
55 | geom = "violin",
56 | stat = StatYdensity,
57 | position = "dodge",
58 | x = sex,
59 | y = body_mass_g,
60 | col = species,
61 | )
62 |
63 | vdiffr::expect_doppelganger(test_name, p)
64 | })
65 |
66 | test_name <- "PositionDodge"
67 |
68 | test_that(test_name, {
69 | p <- penguins |>
70 | drop_na(sex) |>
71 | mutate(across(sex, \(x) str_to_sentence(x))) |>
72 | gg_blanket(
73 | geom = "violin",
74 | stat = "ydensity",
75 | position = PositionDodge,
76 | x = sex,
77 | y = body_mass_g,
78 | col = species,
79 | )
80 |
81 | vdiffr::expect_doppelganger(test_name, p)
82 | })
83 |
84 | test_name <- "all 3"
85 |
86 | test_that(test_name, {
87 | p <- penguins |>
88 | drop_na(sex) |>
89 | mutate(across(sex, \(x) str_to_sentence(x))) |>
90 | gg_blanket(
91 | geom = GeomViolin,
92 | stat = StatYdensity,
93 | position = PositionDodge,
94 | x = sex,
95 | y = body_mass_g,
96 | col = species,
97 | )
98 |
99 | vdiffr::expect_doppelganger(test_name, p)
100 | })
101 |
--------------------------------------------------------------------------------
/R/aes.R:
--------------------------------------------------------------------------------
1 | #' Get a dark/light colour for contrast
2 | #'
3 | #' @description Get a dark/light colour based on contrast with fill colours
4 | #'
5 | #' @param fill A fill aesthetic from which to determine the colour scale for contrast.
6 | #' @param ... Provided to require argument naming, support trailing commas etc.
7 | #' @param dark A dark colour.
8 | #' @param light A light colour.
9 | #'
10 | #' @noRd
11 | #'
12 | #' @examples
13 | #' get_contrast(fill = c("navy", "yellow", "orange"), dark = "black", light = "white")
14 | #'
15 | get_contrast <- function(fill, ..., dark = "#121B24FF", light = "#FFFFFFFF") {
16 | ifelse(
17 | farver::get_channel(
18 | colour = fill,
19 | channel = "l",
20 | space = "hcl"
21 | ) <
22 | 50,
23 | light,
24 | dark
25 | )
26 | }
27 |
28 | #' A colour aesthetic for contrast
29 | #'
30 | #' @description A colour aesthetic to contrast with a fill aesthetic. Can be spliced into [ggplot2::aes] with [rlang::!!!].
31 | #'
32 | #' @param ... Provided to require argument naming, support trailing commas etc.
33 | #' @param dark A dark colour.
34 | #' @param light A light colour.
35 | #'
36 | #' @return A ggplot2 aesthetic
37 | #' @export
38 | #'
39 | #' @examples
40 | #' library(ggplot2)
41 | #' library(dplyr)
42 | #' library(stringr)
43 | #' library(palmerpenguins)
44 | #'
45 | #' set_blanket()
46 | #'
47 | #' penguins |>
48 | #' count(species, sex) |>
49 | #' gg_col(
50 | #' x = sex,
51 | #' y = n,
52 | #' col = species,
53 | #' label = n,
54 | #' position = position_dodge(preserve = "single"),
55 | #' width = 0.75,
56 | #' x_labels = \(x) str_to_sentence(x),
57 | #' ) +
58 | #' geom_text(
59 | #' mapping = aes_contrast(),
60 | #' position = position_dodge(width = 0.75, preserve = "single"),
61 | #' vjust = 1.33,
62 | #' show.legend = FALSE,
63 | #' )
64 | #'
65 | #' penguins |>
66 | #' count(species, sex) |>
67 | #' gg_col(
68 | #' x = sex,
69 | #' y = n,
70 | #' col = species,
71 | #' position = position_dodge(preserve = "single"),
72 | #' width = 0.75,
73 | #' x_labels = \(x) str_to_sentence(x),
74 | #' theme = dark_mode_r(),
75 | #' ) +
76 | #' geom_text(
77 | #' mapping = aes(label = n, !!!aes_contrast(dark = darkness[3], light = darkness[1])),
78 | #' position = position_dodge(width = 0.75, preserve = "single"),
79 | #' vjust = 1.33,
80 | #' show.legend = FALSE,
81 | #' )
82 | aes_contrast <- function(..., dark = "#121B24FF", light = "#FFFFFFFF") {
83 | ggplot2::aes(
84 | colour = ggplot2::after_scale(
85 | get_contrast(.data$fill, dark = dark, light = light)
86 | )
87 | )
88 | }
89 |
--------------------------------------------------------------------------------
/man/scale_x_symmetric.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/scale_symmetric.R
3 | \name{scale_x_symmetric}
4 | \alias{scale_x_symmetric}
5 | \title{Symmetric x continuous scale}
6 | \usage{
7 | scale_x_symmetric(
8 | data = NULL,
9 | x = NULL,
10 | ...,
11 | breaks = NULL,
12 | breaks_n = 6,
13 | expand = NULL,
14 | expand_limits = NULL,
15 | labels = NULL,
16 | position = "bottom",
17 | sec_axis = ggplot2::waiver(),
18 | transform = "identity",
19 | symmetric = TRUE
20 | )
21 | }
22 | \arguments{
23 | \item{data}{A data frame or tibble.}
24 |
25 | \item{x}{An unquoted variable.}
26 |
27 | \item{...}{Provided to force user argument naming etc.}
28 |
29 | \item{breaks}{A \verb{scales::breaks_*} function (e.g. \verb{scales::breaks_*()}), or a vector of breaks.}
30 |
31 | \item{breaks_n}{If \code{breaks = NULL}, the desired number of breaks.}
32 |
33 | \item{expand}{Padding to the limits with the \code{\link[ggplot2:expansion]{ggplot2::expansion()}} function, or a vector of length 2 (e.g. \code{c(0, 0)}).}
34 |
35 | \item{expand_limits}{Any values that the limits should encompass (e.g. \code{0}).}
36 |
37 | \item{labels}{A function that takes the breaks as inputs (e.g. \verb{\\(x) stringr::str_to_sentence(x)} or \verb{scales::label_*()}), or a vector of labels.}
38 |
39 | \item{position}{The position of the axis (i.e. \code{"left"}, \code{"right"}, \code{"bottom"} or \code{"top"}).}
40 |
41 | \item{sec_axis}{A secondary axis created with \code{\link[ggplot2:sec_axis]{ggplot2::sec_axis()}} or \code{\link[ggplot2:sec_axis]{ggplot2::dup_axis()}}.}
42 |
43 | \item{transform}{A transformation object (e.g. \code{\link[scales:transform_log]{scales::transform_log10()}}) or character string of this minus the \code{transform_} prefix (e.g. \code{"log10"}).}
44 |
45 | \item{symmetric}{\code{TRUE} or \code{FALSE} of whether a symmetric scale.}
46 | }
47 | \value{
48 | A ggplot2 continuous x scale.
49 | }
50 | \description{
51 | Create a symmetric continuous x scale for ggplot2 plots.
52 | The scale ensures that limits set to the range of breaks with zero expand (where \code{symmetric = TRUE}).
53 | Note this scale should only be used in plots with geoms with \code{stat = "identity"}.
54 | }
55 | \examples{
56 | library(ggplot2)
57 | library(dplyr)
58 | library(palmerpenguins)
59 |
60 | set_blanket()
61 |
62 | penguins |>
63 | ggplot() +
64 | geom_jitter(aes(x = body_mass_g, y = species, colour = species)) +
65 | scale_x_symmetric(penguins, body_mass_g) +
66 | theme(axis.line.x = element_blank()) +
67 | theme(axis.ticks.x = element_blank()) +
68 | theme(panel.grid.major.y = element_blank()) +
69 | theme(axis.ticks.y = element_blank()) +
70 | coord_cartesian(clip = "off") +
71 | labs(x = "Body mass g", y = "Species", colour = "Species")
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/man/scale_y_symmetric.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/scale_symmetric.R
3 | \name{scale_y_symmetric}
4 | \alias{scale_y_symmetric}
5 | \title{Symmetric y continuous scale}
6 | \usage{
7 | scale_y_symmetric(
8 | data = NULL,
9 | y = NULL,
10 | ...,
11 | breaks = NULL,
12 | breaks_n = 6,
13 | expand = NULL,
14 | expand_limits = NULL,
15 | labels = NULL,
16 | position = "left",
17 | sec_axis = ggplot2::waiver(),
18 | transform = "identity",
19 | symmetric = TRUE
20 | )
21 | }
22 | \arguments{
23 | \item{data}{A data frame or tibble.}
24 |
25 | \item{y}{An unquoted variable.}
26 |
27 | \item{...}{Provided to force user argument naming etc.}
28 |
29 | \item{breaks}{A \verb{scales::breaks_*} function (e.g. \verb{scales::breaks_*()}), or a vector of breaks.}
30 |
31 | \item{breaks_n}{If \code{breaks = NULL}, the desired number of breaks.}
32 |
33 | \item{expand}{Padding to the limits with the \code{\link[ggplot2:expansion]{ggplot2::expansion()}} function, or a vector of length 2 (e.g. \code{c(0, 0)}).}
34 |
35 | \item{expand_limits}{Any values that the limits should encompass (e.g. \code{0}).}
36 |
37 | \item{labels}{A function that takes the breaks as inputs (e.g. \verb{\\(x) stringr::str_to_sentence(x)} or \verb{scales::label_*()}), or a vector of labels.}
38 |
39 | \item{position}{The position of the axis (i.e. \code{"left"}, \code{"right"}, \code{"bottom"} or \code{"top"}).}
40 |
41 | \item{sec_axis}{A secondary axis created with \code{\link[ggplot2:sec_axis]{ggplot2::sec_axis()}} or \code{\link[ggplot2:sec_axis]{ggplot2::dup_axis()}}.}
42 |
43 | \item{transform}{A transformation object (e.g. \code{\link[scales:transform_log]{scales::transform_log10()}}) or character string of this minus the \code{transform_} prefix (e.g. \code{"log10"}).}
44 |
45 | \item{symmetric}{\code{TRUE} or \code{FALSE} of whether a symmetric scale.}
46 | }
47 | \value{
48 | A ggplot2 continuous y scale.
49 | }
50 | \description{
51 | Create a symmetric continuous y scale for ggplot2 plots.
52 | The scale ensures that limits set to the range of breaks with zero expand (where \code{symmetric = TRUE}).
53 | Note this scale should only be used in plots with geoms with \code{stat = "identity"}.
54 | Symmetric y continuous scale
55 | }
56 | \examples{
57 | library(ggplot2)
58 | library(dplyr)
59 | library(palmerpenguins)
60 |
61 | set_blanket()
62 |
63 | penguins |>
64 | ggplot() +
65 | geom_point(aes(x = flipper_length_mm, y = body_mass_g, colour = species)) +
66 | scale_y_symmetric(penguins, body_mass_g) +
67 | theme(axis.line.y = element_blank()) +
68 | theme(axis.ticks.y = element_blank()) +
69 | theme(panel.grid.major.x = element_blank()) +
70 | coord_cartesian(clip = "off") +
71 | labs(x = "Flipper length mm", y = "Body mass g", colour = "Species")
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/tests/testthat/test-set_blanket.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(palmerpenguins)
5 | library(ggplot2)
6 | library(dplyr)
7 |
8 | ###
9 | test_name <- "1"
10 |
11 | test_that(test_name, {
12 | set_blanket(
13 | theme = theme_grey(),
14 | theme_axis_line_rm = FALSE,
15 | theme_axis_ticks_rm = FALSE,
16 | theme_panel_grid_rm = FALSE
17 | )
18 |
19 | p <- penguins |>
20 | mutate(across(sex, \(x) stringr::str_to_sentence(x))) |>
21 | gg_point(
22 | x = flipper_length_mm,
23 | y = body_mass_g,
24 | col = sex,
25 | ) +
26 | geom_vline(xintercept = 200)
27 |
28 | vdiffr::expect_doppelganger(test_name, p)
29 | })
30 |
31 | ###
32 | test_name <- "2"
33 |
34 | test_that(test_name, {
35 | set_blanket(
36 | theme = light_mode_r(),
37 | colour = red,
38 | )
39 |
40 | update_geom_defaults("text", aes(colour = teal))
41 |
42 | update_geom_defaults("vline", aes(colour = teal))
43 |
44 | p <- penguins |>
45 | mutate(across(sex, \(x) stringr::str_to_sentence(x))) |>
46 | gg_point(
47 | x = flipper_length_mm,
48 | y = body_mass_g,
49 | col = sex,
50 | ) +
51 | geom_vline(xintercept = 200)
52 |
53 | vdiffr::expect_doppelganger(test_name, p)
54 | })
55 |
56 | ###
57 |
58 | set_blanket(
59 | theme = dark_mode_r(base_size = 15),
60 | colour = red,
61 | col_palette_d = c(navy, red, "green"),
62 | col_palette_c = c(navy, purple, red, orange)
63 | )
64 |
65 | update_geom_defaults("text", aes(colour = "red", size = 15 / 2.83505))
66 |
67 | update_geom_defaults("vline", aes(colour = "red", linewidth = 5))
68 |
69 | ###
70 | test_name <- "3"
71 |
72 | test_that(test_name, {
73 | p <- penguins |>
74 | gg_point(
75 | x = flipper_length_mm,
76 | y = body_mass_g,
77 | x_breaks = scales::breaks_pretty(3),
78 | ) +
79 | geom_vline(xintercept = 200) +
80 | annotate("text", x = I(0.25), y = I(0.75), label = "Here")
81 |
82 | vdiffr::expect_doppelganger(test_name, p)
83 | })
84 |
85 | ###
86 | test_name <- "4"
87 |
88 | test_that(test_name, {
89 | p <- penguins |>
90 | gg_point(
91 | x = flipper_length_mm,
92 | y = body_mass_g,
93 | col = species,
94 | x_breaks = scales::breaks_pretty(3),
95 | ) +
96 | geom_vline(xintercept = 200) +
97 | annotate("text", x = I(0.25), y = I(0.75), label = "Here")
98 |
99 | vdiffr::expect_doppelganger(test_name, p)
100 | })
101 |
102 | ###
103 | test_name <- "5"
104 |
105 | test_that(test_name, {
106 | p <- penguins |>
107 | gg_point(
108 | x = flipper_length_mm,
109 | y = body_mass_g,
110 | col = bill_depth_mm,
111 | x_breaks = scales::breaks_pretty(3),
112 | ) +
113 | geom_vline(xintercept = 200) +
114 | annotate("text", x = I(0.25), y = I(0.75), label = "Here")
115 |
116 | vdiffr::expect_doppelganger(test_name, p)
117 | })
118 |
119 | ###
120 | test_name <- "6"
121 |
122 | test_that(test_name, {
123 | p <- penguins |>
124 | mutate(across(sex, \(x) stringr::str_to_sentence(x))) |>
125 | gg_smooth(
126 | x = flipper_length_mm,
127 | y = body_mass_g,
128 | col = species,
129 | se = TRUE,
130 | ) +
131 | geom_vline(xintercept = 200) +
132 | annotate("text", x = I(0.25), y = I(0.75), label = "Here")
133 |
134 | vdiffr::expect_doppelganger(test_name, p)
135 | })
136 |
137 | set_blanket()
138 |
--------------------------------------------------------------------------------
/man/set_blanket.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/set.R
3 | \name{set_blanket}
4 | \alias{set_blanket}
5 | \title{Set the style}
6 | \usage{
7 | set_blanket(
8 | ...,
9 | theme = light_mode_r(),
10 | theme_orientation = NULL,
11 | theme_axis_line_rm = TRUE,
12 | theme_axis_ticks_rm = TRUE,
13 | theme_panel_grid_rm = TRUE,
14 | col_palette_d = jumble,
15 | col_palette_c = viridisLite::mako(n = 9, direction = -1),
16 | col_palette_o = scales::pal_viridis(option = "G", direction = -1),
17 | col_palette_na_d = "#CDC5BFFF",
18 | col_palette_na_c = "#988F88FF",
19 | col_palette_na_o = "#988F88FF",
20 | colour = "#357BA2FF",
21 | fill = colour,
22 | linewidth = 0.66,
23 | label_case = snakecase::to_sentence_case
24 | )
25 | }
26 | \arguments{
27 | \item{...}{Provided to require argument naming, support trailing commas etc.}
28 |
29 | \item{theme}{A ggplot2 theme (e.g. \code{\link[=light_mode_t]{light_mode_t()}} or \code{\link[=dark_mode_r]{dark_mode_r()}}).}
30 |
31 | \item{theme_orientation}{The orientation of plot, which affects the theme components that can be removed by the \verb{gg_*} function. Either \code{"x"} or \code{"y"}. Defaults to \code{NULL}, which lets the \verb{gg_*} function guess it based on the data.}
32 |
33 | \item{theme_axis_line_rm}{\code{TRUE} or \code{FALSE} of whether the \verb{gg_*} function should remove the relevant axis line per the \code{theme_orientation} of the plot.}
34 |
35 | \item{theme_axis_ticks_rm}{\code{TRUE} or \code{FALSE} of whether the \verb{gg_*} function should remove the relevant axis ticks per the \code{theme_orientation} of the plot.}
36 |
37 | \item{theme_panel_grid_rm}{\code{TRUE} or \code{FALSE} of whether the \verb{gg_*} function should remove the relevant panel grid per the \code{theme_orientation} of the plot.}
38 |
39 | \item{col_palette_d}{For a discrete scale, a character vector of hex codes.}
40 |
41 | \item{col_palette_c}{For a continuous scale, a character vector of hex codes.}
42 |
43 | \item{col_palette_o}{For an ordinal scale, a \verb{scales::pal_*()} function.}
44 |
45 | \item{col_palette_na_d}{For a discrete scale, a hex code.}
46 |
47 | \item{col_palette_na_c}{For a continuous scale, a hex code.}
48 |
49 | \item{col_palette_na_o}{For an ordinal scale, a hex code.}
50 |
51 | \item{colour}{A default hex code for the colour of geoms (i.e. geoms other than "text", "label", "hline", and "vline"). Note, the "fill" inherits from this argument.}
52 |
53 | \item{fill}{A default hex code for the fill of relevant geoms (i.e. geoms other than "label"). Inherits from colour.}
54 |
55 | \item{linewidth}{A numeric linewidth (i.e. for geoms that are polygons, and do not potentially have necessary adjacent lines - these get a linewidth of 0). Defaults to 0.66.}
56 |
57 | \item{label_case}{A function to apply to a unspecified/unlabelled \code{x_label}, \code{y_label}, \code{col_label} etc. Defaults to \code{snakecase::to_sentence_case}.}
58 | }
59 | \value{
60 | A globally set style.
61 | }
62 | \description{
63 | Set the style by setting:
64 | \enumerate{
65 | \item the theme, and how/what side-effects are to be applied
66 | \item the geom defaults, including the colour (and fill) of geoms
67 | \item the geom colour (and fill) palettes (i.e. discrete, continuous and ordinal)
68 | \item the function to apply to a unspecified/unlabelled \code{x_label}, \code{y_label}, \code{col_label} etc.
69 | }
70 |
71 | \code{\link[ggplot2:update_defaults]{ggplot2::update_geom_defaults()}} can be used to further fine-tune geom defaults.
72 | }
73 | \examples{
74 | library(ggplot2)
75 | library(ggblanket)
76 | library(palmerpenguins)
77 |
78 | set_blanket(
79 | theme = dark_mode_r(),
80 | colour = "#E7298AFF",
81 | col_palette_d = c("#1B9E77FF", "#D95F02FF", "#7570b3FF", "#E7298AFF",
82 | "#66A61EFF", "#E6AB02FF", "#A6761DFF", "#666666FF"),
83 | )
84 |
85 | penguins |>
86 | gg_point(
87 | x = flipper_length_mm,
88 | y = body_mass_g,
89 | )
90 |
91 | penguins |>
92 | gg_histogram(
93 | x = flipper_length_mm,
94 | col = species,
95 | )
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/R/bind_each_all.R:
--------------------------------------------------------------------------------
1 | #' Bind each all.
2 | #'
3 | #' @description
4 | #' Binds data to support plotting each category _and_ all combined data.
5 | #'
6 | #' @param data A data frame or tibble.
7 | #' @param ... An unquoted variable.
8 | #' @param name A variable name. Defaults to `each_all`.
9 | #' @param each A string for the each value. Defaults to `"Each"`.
10 | #' @param all A string for the all value. Defaults to `"All"`.
11 | #' @param all_after A number for where the all value should be placed after. Use `0` for first or `Inf` for last. Defaults to `Inf`.
12 | #'
13 | #' @return A data frame or tibble
14 | #' @export
15 | #'
16 | #' @examples
17 | #' library(dplyr)
18 | #' library(ggplot2)
19 | #' library(palmerpenguins)
20 | #'
21 | #' set_blanket()
22 | #'
23 | #' penguins |>
24 | #' count(species)
25 | #'
26 | #' penguins |>
27 | #' bind_each_all(species) |>
28 | #' count(species, each_all)
29 | #'
30 | #' penguins |>
31 | #' bind_each_all(species) |>
32 | #' gg_jitter(
33 | #' x = species,
34 | #' y = body_mass_g,
35 | #' )
36 | #'
37 | #' penguins |>
38 | #' bind_each_all(species) |>
39 | #' gg_jitter(
40 | #' x = species,
41 | #' y = body_mass_g,
42 | #' col = each_all,
43 | #' col_palette = c(blue, grey),
44 | #' ) +
45 | #' theme(legend.position = "none")
46 | #'
47 | #' penguins |>
48 | #' bind_each_all(species) |>
49 | #' group_by(species, each_all) |>
50 | #' summarise(across(body_mass_g, \(x) mean(x, na.rm = TRUE))) |>
51 | #' gg_col(
52 | #' x = species,
53 | #' y = body_mass_g,
54 | #' col = each_all,
55 | #' col_palette = c(blue, grey),
56 | #' width = 0.5,
57 | #' y_label = "Average body mass g",
58 | #' ) +
59 | #' theme(legend.position = "none")
60 | #'
61 | #' penguins |>
62 | #' bind_each_all(species, all = "All\nspecies") |>
63 | #' gg_jitter(
64 | #' x = species,
65 | #' y = body_mass_g,
66 | #' col = each_all,
67 | #' col_palette = c(blue, grey),
68 | #' facet = each_all,
69 | #' facet_layout = "grid",
70 | #' facet_scales = "free_x",
71 | #' facet_space = "free_x",
72 | #' ) +
73 | #' theme(legend.position = "none") +
74 | #' theme(strip.text.x = element_blank()) +
75 | #' labs(x = NULL)
76 | #'
77 | bind_each_all <- function(
78 | data,
79 | ...,
80 | name = "each_all",
81 | each = "Each",
82 | all = "All",
83 | all_after = Inf
84 | ) {
85 | if (...length() != 1) {
86 | stop("Please provide one variable")
87 | }
88 | by <- rlang::enquos(...)[1][[1]]
89 | if (inherits(rlang::eval_tidy(by, data), what = c("factor"))) {
90 | levels <- levels(rlang::eval_tidy(by, data))
91 | data <- data |>
92 | dplyr::bind_rows(dplyr::mutate(data, !!by := all)) |>
93 | dplyr::mutate(!!by := factor(!!by, levels = c(levels, all))) |>
94 | dplyr::mutate(
95 | !!by := {
96 | col_values <- !!by
97 | if (any(is.na(col_values))) {
98 | forcats::fct_relevel(
99 | forcats::fct_na_value_to_level(col_values),
100 | all,
101 | after = all_after
102 | )
103 | } else {
104 | forcats::fct_relevel(col_values, all, after = all_after)
105 | }
106 | }
107 | )
108 | } else {
109 | data <- data |>
110 | dplyr::mutate(!!by := as.character(!!by)) |>
111 | dplyr::bind_rows(dplyr::mutate(data, !!by := all)) |>
112 | dplyr::mutate(
113 | !!by := {
114 | col_values <- !!by
115 | if (any(is.na(col_values))) {
116 | forcats::fct_relevel(
117 | forcats::fct_na_value_to_level(col_values),
118 | all,
119 | after = all_after
120 | )
121 | } else {
122 | forcats::fct_relevel(as.factor(col_values), all, after = all_after)
123 | }
124 | }
125 | )
126 | }
127 | data <- data |>
128 | dplyr::mutate(
129 | !!name := dplyr::if_else(!!by == all, all, each, missing = each)
130 | ) |>
131 | dplyr::mutate(dplyr::across(!!name, forcats::fct_inorder))
132 | if (all_after == 0) {
133 | data <- data |>
134 | dplyr::mutate(dplyr::across(!!name, forcats::fct_rev))
135 | }
136 | return(data)
137 | }
138 |
--------------------------------------------------------------------------------
/R/set.R:
--------------------------------------------------------------------------------
1 | #' Set the style
2 | #'
3 | #' @description
4 | #' Set the style by setting:
5 | #'
6 | #' 1. the theme, and how/what side-effects are to be applied
7 | #' 2. the geom defaults, including the colour (and fill) of geoms
8 | #' 3. the geom colour (and fill) palettes (i.e. discrete, continuous and ordinal)
9 | #' 4. the function to apply to a unspecified/unlabelled `x_label`, `y_label`, `col_label` etc.
10 | #'
11 | #' [ggplot2::update_geom_defaults()] can be used to further fine-tune geom defaults.
12 | #'
13 | #' @param ... Provided to require argument naming, support trailing commas etc.
14 | #' @param theme A ggplot2 theme (e.g. [light_mode_t()] or [dark_mode_r()]).
15 | #' @param theme_orientation The orientation of plot, which affects the theme components that can be removed by the `gg_*` function. Either `"x"` or `"y"`. Defaults to `NULL`, which lets the `gg_*` function guess it based on the data.
16 | #' @param theme_axis_line_rm `TRUE` or `FALSE` of whether the `gg_*` function should remove the relevant axis line per the `theme_orientation` of the plot.
17 | #' @param theme_axis_ticks_rm `TRUE` or `FALSE` of whether the `gg_*` function should remove the relevant axis ticks per the `theme_orientation` of the plot.
18 | #' @param theme_panel_grid_rm `TRUE` or `FALSE` of whether the `gg_*` function should remove the relevant panel grid per the `theme_orientation` of the plot.
19 | #' @param colour A default hex code for the colour of geoms (i.e. geoms other than "text", "label", "hline", and "vline"). Note, the "fill" inherits from this argument.
20 | #' @param fill A default hex code for the fill of relevant geoms (i.e. geoms other than "label"). Inherits from colour.
21 | #' @param linewidth A numeric linewidth (i.e. for geoms that are polygons, and do not potentially have necessary adjacent lines - these get a linewidth of 0). Defaults to 0.66.
22 | #' @param col_palette_d For a discrete scale, a character vector of hex codes.
23 | #' @param col_palette_c For a continuous scale, a character vector of hex codes.
24 | #' @param col_palette_o For an ordinal scale, a `scales::pal_*()` function.
25 | #' @param col_palette_na_d For a discrete scale, a hex code.
26 | #' @param col_palette_na_c For a continuous scale, a hex code.
27 | #' @param col_palette_na_o For an ordinal scale, a hex code.
28 | #' @param label_case A function to apply to a unspecified/unlabelled `x_label`, `y_label`, `col_label` etc. Defaults to `snakecase::to_sentence_case`.
29 | #'
30 | #' @return A globally set style.
31 | #' @export
32 | #'
33 | #' @examples
34 | #' library(ggplot2)
35 | #' library(ggblanket)
36 | #' library(palmerpenguins)
37 | #'
38 | #' set_blanket(
39 | #' theme = dark_mode_r(),
40 | #' colour = "#E7298AFF",
41 | #' col_palette_d = c("#1B9E77FF", "#D95F02FF", "#7570b3FF", "#E7298AFF",
42 | #' "#66A61EFF", "#E6AB02FF", "#A6761DFF", "#666666FF"),
43 | #' )
44 | #'
45 | #' penguins |>
46 | #' gg_point(
47 | #' x = flipper_length_mm,
48 | #' y = body_mass_g,
49 | #' )
50 | #'
51 | #' penguins |>
52 | #' gg_histogram(
53 | #' x = flipper_length_mm,
54 | #' col = species,
55 | #' )
56 | #'
57 | set_blanket <- function(
58 | ...,
59 | theme = light_mode_r(),
60 | theme_orientation = NULL,
61 | theme_axis_line_rm = TRUE,
62 | theme_axis_ticks_rm = TRUE,
63 | theme_panel_grid_rm = TRUE,
64 | col_palette_d = jumble,
65 | col_palette_c = viridisLite::mako(n = 9, direction = -1),
66 | col_palette_o = scales::pal_viridis(option = "G", direction = -1),
67 | col_palette_na_d = "#CDC5BFFF",
68 | col_palette_na_c = "#988F88FF",
69 | col_palette_na_o = "#988F88FF",
70 | colour = "#357BA2FF",
71 | fill = colour,
72 | linewidth = 0.66,
73 | label_case = snakecase::to_sentence_case
74 | ) {
75 | weave_theme(
76 | theme = theme,
77 | theme_orientation = theme_orientation,
78 | theme_axis_line_rm = theme_axis_line_rm,
79 | theme_axis_ticks_rm = theme_axis_ticks_rm,
80 | theme_panel_grid_rm = theme_panel_grid_rm
81 | )
82 |
83 | weave_geom_base(colour = colour, fill = fill, linewidth = linewidth)
84 |
85 | weave_geom_text()
86 |
87 | weave_geom_label()
88 |
89 | weave_geom_reference_line()
90 |
91 | weave_col_palettes(
92 | col_palette_d = col_palette_d,
93 | col_palette_c = col_palette_c,
94 | col_palette_o = col_palette_o,
95 | col_palette_na_d = col_palette_na_d,
96 | col_palette_na_c = col_palette_na_c,
97 | col_palette_na_o = col_palette_na_o
98 | )
99 |
100 | weave_label_case(label_case = label_case)
101 | }
102 |
--------------------------------------------------------------------------------
/man/flex_mode_base.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/flex_mode.R
3 | \name{flex_mode_base}
4 | \alias{flex_mode_base}
5 | \title{Mode theme base}
6 | \usage{
7 | flex_mode_base(
8 | base_size = 11,
9 | base_family = "",
10 | base_colour = "#121B24FF",
11 | base_face = "plain",
12 | plot_title_size = ggplot2::rel(1.1),
13 | plot_title_family = base_family,
14 | plot_title_colour = base_colour,
15 | plot_title_face = "bold",
16 | plot_subtitle_size = ggplot2::rel(1),
17 | plot_subtitle_family = base_family,
18 | plot_subtitle_colour = base_colour,
19 | plot_subtitle_face = "plain",
20 | plot_caption_size = ggplot2::rel(0.85),
21 | plot_caption_family = base_family,
22 | plot_caption_colour = colorspace::lighten(base_colour, 0.1),
23 | plot_caption_face = "plain",
24 | plot_caption_hjust = 0,
25 | axis_line_colour = "#121B24FF",
26 | axis_line_linewidth = 0.25,
27 | axis_ticks_colour = axis_line_colour,
28 | axis_ticks_linewidth = axis_line_linewidth,
29 | axis_ticks_length = grid::unit(11/3, "pt"),
30 | panel_grid_colour = "#F6F8FAFF",
31 | panel_grid_linewidth = 1.33,
32 | panel_background_fill = "#FFFFFFFF",
33 | plot_background_fill = "#FFFFFFFF",
34 | legend_axis_line_colour = plot_background_fill,
35 | legend_axis_line_linewidth = axis_line_linewidth,
36 | legend_background_fill = plot_background_fill,
37 | legend_key_fill = plot_background_fill,
38 | legend_ticks_colour = legend_axis_line_colour,
39 | legend_ticks_linewidth = legend_axis_line_linewidth,
40 | legend_ticks_length = ggplot2::rel(c(0.175, 0))
41 | )
42 | }
43 | \arguments{
44 | \item{base_size}{The base size of the text theme element. Defaults to 11.}
45 |
46 | \item{base_family}{The base family of the text theme element. Defaults to "".}
47 |
48 | \item{base_colour}{The base colour of the text theme element.}
49 |
50 | \item{base_face}{The base face of the text theme element. Defaults to "plain".}
51 |
52 | \item{plot_title_size}{The size of the plot.title theme element.}
53 |
54 | \item{plot_title_family}{The family of the plot.title theme element.}
55 |
56 | \item{plot_title_colour}{The colour of the plot.title theme element.}
57 |
58 | \item{plot_title_face}{The face of the plot.title theme element.}
59 |
60 | \item{plot_subtitle_size}{The size of the plot.subtitle theme element.}
61 |
62 | \item{plot_subtitle_family}{The family of the plot.subtitle theme element.}
63 |
64 | \item{plot_subtitle_colour}{The colour of the plot.subtitle theme element.}
65 |
66 | \item{plot_subtitle_face}{The face of the plot.subtitle theme element.}
67 |
68 | \item{plot_caption_size}{The size of the plot.caption theme element.}
69 |
70 | \item{plot_caption_family}{The family of the plot.caption theme element.}
71 |
72 | \item{plot_caption_colour}{The colour of the plot.caption theme element.}
73 |
74 | \item{plot_caption_face}{The face of the plot.caption theme element.}
75 |
76 | \item{plot_caption_hjust}{The horizontal adjustment of the plot.caption theme element.}
77 |
78 | \item{axis_line_colour}{The colour of the axis.line theme element.}
79 |
80 | \item{axis_line_linewidth}{The linewidth of the axis.line theme element.}
81 |
82 | \item{axis_ticks_colour}{The colour of the axis.ticks theme element.}
83 |
84 | \item{axis_ticks_linewidth}{The linewidth of the axis.ticks theme element.}
85 |
86 | \item{axis_ticks_length}{The length of the axis.ticks.length theme element.}
87 |
88 | \item{panel_grid_colour}{The colour of the panel.grid theme element.}
89 |
90 | \item{panel_grid_linewidth}{The linewidth of the panel.grid theme element.}
91 |
92 | \item{panel_background_fill}{The fill (and colour) of the panel.background theme element.}
93 |
94 | \item{plot_background_fill}{The fill (and colour) of the plot.background theme element.}
95 |
96 | \item{legend_axis_line_colour}{The colour of the legend.axis.line theme element.}
97 |
98 | \item{legend_axis_line_linewidth}{The linewidth of the legend.axis.line theme element.}
99 |
100 | \item{legend_background_fill}{The fill (and colour) of the legend.background theme element.}
101 |
102 | \item{legend_key_fill}{The fill (and colour) of the legend.key theme element.}
103 |
104 | \item{legend_ticks_colour}{The colour of the legend.ticks theme element.}
105 |
106 | \item{legend_ticks_linewidth}{The linewidth of the legend.ticks theme element.}
107 |
108 | \item{legend_ticks_length}{The legend.ticks.length theme element.}
109 | }
110 | \value{
111 | A ggplot theme.
112 | }
113 | \description{
114 | Theme base for \verb{*_mode_*} functions.
115 | }
116 | \keyword{internal}
117 |
--------------------------------------------------------------------------------
/man/flex_mode_t.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/flex_mode.R
3 | \name{flex_mode_t}
4 | \alias{flex_mode_t}
5 | \title{Flexible mode with top legend}
6 | \usage{
7 | flex_mode_t(
8 | ...,
9 | base_size = 11,
10 | base_family = "",
11 | base_face = "plain",
12 | base_colour = "#121B24FF",
13 | plot_title_size = ggplot2::rel(1.1),
14 | plot_title_family = base_family,
15 | plot_title_face = "bold",
16 | plot_title_colour = base_colour,
17 | plot_subtitle_size = ggplot2::rel(1),
18 | plot_subtitle_family = base_family,
19 | plot_subtitle_face = "plain",
20 | plot_subtitle_colour = base_colour,
21 | plot_caption_size = ggplot2::rel(0.85),
22 | plot_caption_family = base_family,
23 | plot_caption_face = "plain",
24 | plot_caption_colour = colorspace::lighten(base_colour, 0.1),
25 | plot_caption_hjust = 0,
26 | axis_line_colour = "#121B24FF",
27 | axis_line_linewidth = 0.25,
28 | axis_ticks_colour = axis_line_colour,
29 | axis_ticks_linewidth = axis_line_linewidth,
30 | axis_ticks_length = grid::unit(3.67, "pt"),
31 | panel_grid_colour = "#F6F8FAFF",
32 | panel_grid_linewidth = 1.33,
33 | panel_background_fill = "#FFFFFFFF",
34 | plot_background_fill = "#FFFFFFFF",
35 | legend_axis_line_colour = plot_background_fill,
36 | legend_axis_line_linewidth = axis_line_linewidth,
37 | legend_background_fill = plot_background_fill,
38 | legend_key_fill = plot_background_fill,
39 | legend_ticks_colour = legend_axis_line_colour,
40 | legend_ticks_linewidth = legend_axis_line_linewidth,
41 | legend_ticks_length = ggplot2::rel(c(0.175, 0))
42 | )
43 | }
44 | \arguments{
45 | \item{...}{Provided to require argument naming, support trailing commas etc.}
46 |
47 | \item{base_size}{The base size of the text theme element. Defaults to 11.}
48 |
49 | \item{base_family}{The base family of the text theme element. Defaults to "".}
50 |
51 | \item{base_face}{The base face of the text theme element. Defaults to "plain".}
52 |
53 | \item{base_colour}{The base colour of the text theme element.}
54 |
55 | \item{plot_title_size}{The size of the plot.title theme element.}
56 |
57 | \item{plot_title_family}{The family of the plot.title theme element.}
58 |
59 | \item{plot_title_face}{The face of the plot.title theme element.}
60 |
61 | \item{plot_title_colour}{The colour of the plot.title theme element.}
62 |
63 | \item{plot_subtitle_size}{The size of the plot.subtitle theme element.}
64 |
65 | \item{plot_subtitle_family}{The family of the plot.subtitle theme element.}
66 |
67 | \item{plot_subtitle_face}{The face of the plot.subtitle theme element.}
68 |
69 | \item{plot_subtitle_colour}{The colour of the plot.subtitle theme element.}
70 |
71 | \item{plot_caption_size}{The size of the plot.caption theme element.}
72 |
73 | \item{plot_caption_family}{The family of the plot.caption theme element.}
74 |
75 | \item{plot_caption_face}{The face of the plot.caption theme element.}
76 |
77 | \item{plot_caption_colour}{The colour of the plot.caption theme element.}
78 |
79 | \item{plot_caption_hjust}{The horizontal adjustment of the plot.caption theme element.}
80 |
81 | \item{axis_line_colour}{The colour of the axis.line theme element.}
82 |
83 | \item{axis_line_linewidth}{The linewidth of the axis.line theme element.}
84 |
85 | \item{axis_ticks_colour}{The colour of the axis.ticks theme element.}
86 |
87 | \item{axis_ticks_linewidth}{The linewidth of the axis.ticks theme element.}
88 |
89 | \item{axis_ticks_length}{The length of the axis.ticks.length theme element.}
90 |
91 | \item{panel_grid_colour}{The colour of the panel.grid theme element.}
92 |
93 | \item{panel_grid_linewidth}{The linewidth of the panel.grid theme element.}
94 |
95 | \item{panel_background_fill}{The fill (and colour) of the panel.background theme element.}
96 |
97 | \item{plot_background_fill}{The fill (and colour) of the plot.background theme element.}
98 |
99 | \item{legend_axis_line_colour}{The colour of the legend.axis.line theme element.}
100 |
101 | \item{legend_axis_line_linewidth}{The linewidth of the legend.axis.line theme element.}
102 |
103 | \item{legend_background_fill}{The fill (and colour) of the legend.background theme element.}
104 |
105 | \item{legend_key_fill}{The fill (and colour) of the legend.key theme element.}
106 |
107 | \item{legend_ticks_colour}{The colour of the legend.ticks theme element.}
108 |
109 | \item{legend_ticks_linewidth}{The linewidth of the legend.ticks theme element.}
110 |
111 | \item{legend_ticks_length}{The legend.ticks.length theme element.}
112 | }
113 | \value{
114 | A ggplot theme.
115 | }
116 | \description{
117 | Flexible mode with legend at top.
118 | }
119 | \keyword{internal}
120 |
--------------------------------------------------------------------------------
/man/flex_mode_r.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/flex_mode.R
3 | \name{flex_mode_r}
4 | \alias{flex_mode_r}
5 | \title{Flexible mode with right legend}
6 | \usage{
7 | flex_mode_r(
8 | ...,
9 | base_size = 11,
10 | base_family = "",
11 | base_face = "plain",
12 | base_colour = "#121B24FF",
13 | plot_title_size = ggplot2::rel(1.1),
14 | plot_title_family = base_family,
15 | plot_title_face = "bold",
16 | plot_title_colour = base_colour,
17 | plot_subtitle_size = ggplot2::rel(1),
18 | plot_subtitle_family = base_family,
19 | plot_subtitle_face = "plain",
20 | plot_subtitle_colour = base_colour,
21 | plot_caption_size = ggplot2::rel(0.85),
22 | plot_caption_family = base_family,
23 | plot_caption_face = "plain",
24 | plot_caption_colour = colorspace::lighten(base_colour, 0.1),
25 | plot_caption_hjust = 0,
26 | axis_line_colour = "#121B24FF",
27 | axis_line_linewidth = 0.25,
28 | axis_ticks_colour = axis_line_colour,
29 | axis_ticks_linewidth = axis_line_linewidth,
30 | axis_ticks_length = grid::unit(3.67, "pt"),
31 | panel_grid_colour = "#F6F8FAFF",
32 | panel_grid_linewidth = 1.33,
33 | panel_background_fill = "#FFFFFFFF",
34 | plot_background_fill = "#FFFFFFFF",
35 | legend_axis_line_colour = plot_background_fill,
36 | legend_axis_line_linewidth = axis_line_linewidth,
37 | legend_background_fill = plot_background_fill,
38 | legend_key_fill = plot_background_fill,
39 | legend_ticks_colour = legend_axis_line_colour,
40 | legend_ticks_linewidth = legend_axis_line_linewidth,
41 | legend_ticks_length = ggplot2::rel(c(0.175, 0))
42 | )
43 | }
44 | \arguments{
45 | \item{...}{Provided to require argument naming, support trailing commas etc.}
46 |
47 | \item{base_size}{The base size of the text theme element. Defaults to 11.}
48 |
49 | \item{base_family}{The base family of the text theme element. Defaults to "".}
50 |
51 | \item{base_face}{The base face of the text theme element. Defaults to "plain".}
52 |
53 | \item{base_colour}{The base colour of the text theme element.}
54 |
55 | \item{plot_title_size}{The size of the plot.title theme element.}
56 |
57 | \item{plot_title_family}{The family of the plot.title theme element.}
58 |
59 | \item{plot_title_face}{The face of the plot.title theme element.}
60 |
61 | \item{plot_title_colour}{The colour of the plot.title theme element.}
62 |
63 | \item{plot_subtitle_size}{The size of the plot.subtitle theme element.}
64 |
65 | \item{plot_subtitle_family}{The family of the plot.subtitle theme element.}
66 |
67 | \item{plot_subtitle_face}{The face of the plot.subtitle theme element.}
68 |
69 | \item{plot_subtitle_colour}{The colour of the plot.subtitle theme element.}
70 |
71 | \item{plot_caption_size}{The size of the plot.caption theme element.}
72 |
73 | \item{plot_caption_family}{The family of the plot.caption theme element.}
74 |
75 | \item{plot_caption_face}{The face of the plot.caption theme element.}
76 |
77 | \item{plot_caption_colour}{The colour of the plot.caption theme element.}
78 |
79 | \item{plot_caption_hjust}{The horizontal adjustment of the plot.caption theme element.}
80 |
81 | \item{axis_line_colour}{The colour of the axis.line theme element.}
82 |
83 | \item{axis_line_linewidth}{The linewidth of the axis.line theme element.}
84 |
85 | \item{axis_ticks_colour}{The colour of the axis.ticks theme element.}
86 |
87 | \item{axis_ticks_linewidth}{The linewidth of the axis.ticks theme element.}
88 |
89 | \item{axis_ticks_length}{The length of the axis.ticks.length theme element.}
90 |
91 | \item{panel_grid_colour}{The colour of the panel.grid theme element.}
92 |
93 | \item{panel_grid_linewidth}{The linewidth of the panel.grid theme element.}
94 |
95 | \item{panel_background_fill}{The fill (and colour) of the panel.background theme element.}
96 |
97 | \item{plot_background_fill}{The fill (and colour) of the plot.background theme element.}
98 |
99 | \item{legend_axis_line_colour}{The colour of the legend.axis.line theme element.}
100 |
101 | \item{legend_axis_line_linewidth}{The linewidth of the legend.axis.line theme element.}
102 |
103 | \item{legend_background_fill}{The fill (and colour) of the legend.background theme element.}
104 |
105 | \item{legend_key_fill}{The fill (and colour) of the legend.key theme element.}
106 |
107 | \item{legend_ticks_colour}{The colour of the legend.ticks theme element.}
108 |
109 | \item{legend_ticks_linewidth}{The linewidth of the legend.ticks theme element.}
110 |
111 | \item{legend_ticks_length}{The legend.ticks.length theme element.}
112 | }
113 | \value{
114 | A ggplot theme.
115 | }
116 | \description{
117 | Flexible mode with right legend.
118 | }
119 | \keyword{internal}
120 |
--------------------------------------------------------------------------------
/man/flex_mode_b.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/flex_mode.R
3 | \name{flex_mode_b}
4 | \alias{flex_mode_b}
5 | \title{Flexible mode with bottom legend}
6 | \usage{
7 | flex_mode_b(
8 | ...,
9 | base_size = 11,
10 | base_family = "",
11 | base_face = "plain",
12 | base_colour = "#121B24FF",
13 | plot_title_size = ggplot2::rel(1.1),
14 | plot_title_family = base_family,
15 | plot_title_face = "bold",
16 | plot_title_colour = base_colour,
17 | plot_subtitle_size = ggplot2::rel(1),
18 | plot_subtitle_family = base_family,
19 | plot_subtitle_face = "plain",
20 | plot_subtitle_colour = base_colour,
21 | plot_caption_size = ggplot2::rel(0.85),
22 | plot_caption_family = base_family,
23 | plot_caption_face = "plain",
24 | plot_caption_colour = colorspace::lighten(base_colour, 0.1),
25 | plot_caption_hjust = 0,
26 | axis_line_colour = "#121B24FF",
27 | axis_line_linewidth = 0.25,
28 | axis_ticks_colour = axis_line_colour,
29 | axis_ticks_linewidth = axis_line_linewidth,
30 | axis_ticks_length = grid::unit(3.67, "pt"),
31 | panel_grid_colour = "#F6F8FAFF",
32 | panel_grid_linewidth = 1.33,
33 | panel_background_fill = "#FFFFFFFF",
34 | plot_background_fill = "#FFFFFFFF",
35 | legend_axis_line_colour = plot_background_fill,
36 | legend_axis_line_linewidth = axis_line_linewidth,
37 | legend_background_fill = plot_background_fill,
38 | legend_key_fill = plot_background_fill,
39 | legend_ticks_colour = legend_axis_line_colour,
40 | legend_ticks_linewidth = legend_axis_line_linewidth,
41 | legend_ticks_length = ggplot2::rel(c(0.175, 0))
42 | )
43 | }
44 | \arguments{
45 | \item{...}{Provided to require argument naming, support trailing commas etc.}
46 |
47 | \item{base_size}{The base size of the text theme element. Defaults to 11.}
48 |
49 | \item{base_family}{The base family of the text theme element. Defaults to "".}
50 |
51 | \item{base_face}{The base face of the text theme element. Defaults to "plain".}
52 |
53 | \item{base_colour}{The base colour of the text theme element.}
54 |
55 | \item{plot_title_size}{The size of the plot.title theme element.}
56 |
57 | \item{plot_title_family}{The family of the plot.title theme element.}
58 |
59 | \item{plot_title_face}{The face of the plot.title theme element.}
60 |
61 | \item{plot_title_colour}{The colour of the plot.title theme element.}
62 |
63 | \item{plot_subtitle_size}{The size of the plot.subtitle theme element.}
64 |
65 | \item{plot_subtitle_family}{The family of the plot.subtitle theme element.}
66 |
67 | \item{plot_subtitle_face}{The face of the plot.subtitle theme element.}
68 |
69 | \item{plot_subtitle_colour}{The colour of the plot.subtitle theme element.}
70 |
71 | \item{plot_caption_size}{The size of the plot.caption theme element.}
72 |
73 | \item{plot_caption_family}{The family of the plot.caption theme element.}
74 |
75 | \item{plot_caption_face}{The face of the plot.caption theme element.}
76 |
77 | \item{plot_caption_colour}{The colour of the plot.caption theme element.}
78 |
79 | \item{plot_caption_hjust}{The horizontal adjustment of the plot.caption theme element.}
80 |
81 | \item{axis_line_colour}{The colour of the axis.line theme element.}
82 |
83 | \item{axis_line_linewidth}{The linewidth of the axis.line theme element.}
84 |
85 | \item{axis_ticks_colour}{The colour of the axis.ticks theme element.}
86 |
87 | \item{axis_ticks_linewidth}{The linewidth of the axis.ticks theme element.}
88 |
89 | \item{axis_ticks_length}{The length of the axis.ticks.length theme element.}
90 |
91 | \item{panel_grid_colour}{The colour of the panel.grid theme element.}
92 |
93 | \item{panel_grid_linewidth}{The linewidth of the panel.grid theme element.}
94 |
95 | \item{panel_background_fill}{The fill (and colour) of the panel.background theme element.}
96 |
97 | \item{plot_background_fill}{The fill (and colour) of the plot.background theme element.}
98 |
99 | \item{legend_axis_line_colour}{The colour of the legend.axis.line theme element.}
100 |
101 | \item{legend_axis_line_linewidth}{The linewidth of the legend.axis.line theme element.}
102 |
103 | \item{legend_background_fill}{The fill (and colour) of the legend.background theme element.}
104 |
105 | \item{legend_key_fill}{The fill (and colour) of the legend.key theme element.}
106 |
107 | \item{legend_ticks_colour}{The colour of the legend.ticks theme element.}
108 |
109 | \item{legend_ticks_linewidth}{The linewidth of the legend.ticks theme element.}
110 |
111 | \item{legend_ticks_length}{The legend.ticks.length theme element.}
112 | }
113 | \value{
114 | A ggplot theme.
115 | }
116 | \description{
117 | Flexible mode with legend at bottom.
118 | }
119 | \keyword{internal}
120 |
--------------------------------------------------------------------------------
/tests/testthat/test-col_palette.R:
--------------------------------------------------------------------------------
1 | testthat::skip_if(getRversion() <= package_version("4.1.0"))
2 | testthat::skip_on_os(c("mac", "linux"))
3 |
4 | library(ggplot2)
5 | library(dplyr)
6 | library(palmerpenguins)
7 |
8 | set_blanket()
9 |
10 | ## ---------------------------------------------------------------------------------------------------
11 | test_name <- "1"
12 |
13 | test_that(test_name, {
14 | p <- faithfuld |>
15 | gg_contour_filled(
16 | x = waiting,
17 | y = eruptions,
18 | z = density,
19 | bins = 8,
20 | )
21 |
22 | vdiffr::expect_doppelganger(test_name, p)
23 | })
24 |
25 | test_name <- "2"
26 |
27 | test_that(test_name, {
28 | set.seed(123)
29 |
30 | p <- penguins |>
31 | gg_point(
32 | x = flipper_length_mm,
33 | y = species,
34 | col = bill_length_mm,
35 | )
36 |
37 | vdiffr::expect_doppelganger(test_name, p)
38 | })
39 |
40 | test_name <- "3"
41 |
42 | test_that(test_name, {
43 | set.seed(123)
44 |
45 | p <- penguins |>
46 | gg_point(
47 | x = flipper_length_mm,
48 | y = species,
49 | col = species,
50 | )
51 |
52 | vdiffr::expect_doppelganger(test_name, p)
53 | })
54 |
55 |
56 | test_name <- "4"
57 |
58 | test_that(test_name, {
59 | p <- faithfuld |>
60 | gg_contour_filled(
61 | x = waiting,
62 | y = eruptions,
63 | z = density,
64 | bins = 8,
65 | col_palette = scales::pal_viridis(option = "A"),
66 | )
67 |
68 | vdiffr::expect_doppelganger(test_name, p)
69 | })
70 |
71 | test_name <- "5"
72 |
73 | test_that(test_name, {
74 | set.seed(123)
75 |
76 | p <- penguins |>
77 | gg_point(
78 | x = flipper_length_mm,
79 | y = species,
80 | col = bill_length_mm,
81 | col_palette = scales::pal_viridis(option = "A"),
82 | )
83 |
84 | vdiffr::expect_doppelganger(test_name, p)
85 | })
86 |
87 | test_name <- "6"
88 |
89 | test_that(test_name, {
90 | set.seed(123)
91 |
92 | p <- penguins |>
93 | gg_point(
94 | x = flipper_length_mm,
95 | y = species,
96 | col = species,
97 | col_palette = scales::pal_viridis(option = "A")
98 | )
99 |
100 | vdiffr::expect_doppelganger(test_name, p)
101 | })
102 |
103 | test_name <- "7"
104 |
105 | test_that(test_name, {
106 | set.seed(123)
107 |
108 | p <- penguins |>
109 | gg_point(
110 | x = flipper_length_mm,
111 | y = species,
112 | col = bill_length_mm,
113 | col_palette = viridisLite::magma(n = 20)
114 | )
115 |
116 | vdiffr::expect_doppelganger(test_name, p)
117 | })
118 |
119 | test_name <- "8"
120 |
121 | test_that(test_name, {
122 | set.seed(123)
123 |
124 | p <- penguins |>
125 | gg_point(
126 | x = flipper_length_mm,
127 | y = species,
128 | col = species,
129 | col_palette = c("red", "blue", "green")
130 | )
131 |
132 | vdiffr::expect_doppelganger(test_name, p)
133 | })
134 |
135 | test_name <- "9"
136 |
137 | test_that(test_name, {
138 | set.seed(123)
139 |
140 | p <- penguins |>
141 | gg_point(
142 | x = flipper_length_mm,
143 | y = species,
144 | col = species,
145 | col_palette = c(
146 | "Gentoo" = "red",
147 | "Adelie" = "blue",
148 | "Chinstrap" = "green"
149 | )
150 | )
151 |
152 | vdiffr::expect_doppelganger(test_name, p)
153 | })
154 |
155 | test_name <- "10"
156 |
157 | test_that(test_name, {
158 | set.seed(123)
159 |
160 | p <- faithfuld |>
161 | gg_contour_filled(
162 | x = waiting,
163 | y = eruptions,
164 | z = density,
165 | bins = 8,
166 | col_palette = viridisLite::magma(n = 8)
167 | )
168 |
169 | vdiffr::expect_doppelganger(test_name, p)
170 | })
171 |
172 | test_name <- "11"
173 |
174 | test_that(test_name, {
175 | set.seed(123)
176 |
177 | p <- data.frame(
178 | trt = factor(c(1, 1, 2, 2)),
179 | resp = c(1, 5, 3, 4),
180 | group = factor(c(1, 2, 1, 2)),
181 | upper = c(1.1, 5.3, 3.3, 4.2),
182 | lower = c(0.8, 4.6, 2.4, 3.6)
183 | ) |>
184 | gg_linerange(
185 | x = trt,
186 | ymin = lower,
187 | ymax = upper,
188 | mapping = aes(colour = group),
189 | position = position_dodge(width = 0.2),
190 | x_label = "Treatment",
191 | y_label = "Response",
192 | )
193 |
194 | vdiffr::expect_doppelganger(test_name, p)
195 | })
196 |
197 | test_name <- "12"
198 |
199 | test_that(test_name, {
200 | set.seed(123)
201 |
202 | p <- mtcars %>%
203 | dplyr::mutate(
204 | cyl = factor(cyl, levels = c("4", "6", "8", "10"))
205 | ) |>
206 | gg_point(
207 | x = mpg,
208 | y = wt,
209 | col = cyl,
210 | )
211 |
212 | vdiffr::expect_doppelganger(test_name, p)
213 | })
214 |
215 |
216 | set_blanket()
217 |
--------------------------------------------------------------------------------
/R/gg_hex.R:
--------------------------------------------------------------------------------
1 | #' Hex ggplot
2 | #'
3 | #' @description Create a hex ggplot with a wrapper around [ggplot2::ggplot()] + [geom_hex()][ggplot2::geom_hex()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' diamonds |>
18 | #' gg_hex(
19 | #' x = carat,
20 | #' y = price,
21 | #' )
22 | #'
23 | gg_hex <- function(
24 | data = NULL,
25 | ...,
26 | stat = "binhex",
27 | position = "identity",
28 | coord = ggplot2::coord_cartesian(clip = "off"),
29 | theme = NULL,
30 | theme_orientation = NULL,
31 | theme_axis_line_rm = NULL,
32 | theme_axis_ticks_rm = NULL,
33 | theme_panel_grid_rm = NULL,
34 | blend = NULL,
35 | x = NULL,
36 | xmin = NULL,
37 | xmax = NULL,
38 | xend = NULL,
39 | y = NULL,
40 | ymin = NULL,
41 | ymax = NULL,
42 | yend = NULL,
43 | z = NULL,
44 | col = NULL,
45 | facet = NULL,
46 | facet2 = NULL,
47 | group = NULL,
48 | subgroup = NULL,
49 | label = NULL,
50 | text = NULL,
51 | sample = NULL,
52 | mapping = NULL,
53 | x_breaks = NULL,
54 | x_breaks_n = NULL,
55 | x_expand = NULL,
56 | x_limits_include = NULL,
57 | x_label = NULL,
58 | x_labels = NULL,
59 | x_position = "bottom",
60 | x_sec_axis = ggplot2::waiver(),
61 | x_symmetric = NULL,
62 | x_transform = NULL,
63 | y_breaks = NULL,
64 | y_breaks_n = NULL,
65 | y_expand = NULL,
66 | y_limits_include = NULL,
67 | y_label = NULL,
68 | y_labels = NULL,
69 | y_position = "left",
70 | y_sec_axis = ggplot2::waiver(),
71 | y_symmetric = NULL,
72 | y_transform = NULL,
73 | col_breaks = NULL,
74 | col_breaks_n = 5,
75 | col_drop = FALSE,
76 | col_limits_include = NULL,
77 | col_label = NULL,
78 | col_labels = NULL,
79 | col_legend_ncol = NULL,
80 | col_legend_nrow = NULL,
81 | col_legend_rev = FALSE,
82 | col_palette = NULL,
83 | col_palette_na = NULL,
84 | col_rescale = scales::rescale(),
85 | col_steps = FALSE,
86 | col_transform = NULL,
87 | facet_axes = NULL,
88 | facet_axis_labels = "margins",
89 | facet_drop = FALSE,
90 | facet_labels = NULL,
91 | facet_layout = NULL,
92 | facet_ncol = NULL,
93 | facet_nrow = NULL,
94 | facet_scales = "fixed",
95 | facet_space = "fixed",
96 | title = NULL,
97 | subtitle = NULL,
98 | caption = NULL,
99 | label_case = NULL
100 | ) {
101 | gg_blanket(
102 | data = data,
103 | geom = "hex",
104 | stat = stat,
105 | position = position,
106 | coord = coord,
107 | theme = theme,
108 | theme_orientation = theme_orientation,
109 | theme_axis_line_rm = theme_axis_line_rm,
110 | theme_axis_ticks_rm = theme_axis_ticks_rm,
111 | theme_panel_grid_rm = theme_panel_grid_rm,
112 | blend = blend,
113 | x = {{ x }},
114 | y = {{ y }},
115 | xmin = {{ xmin }},
116 | xmax = {{ xmax }},
117 | xend = {{ xend }},
118 | ymin = {{ ymin }},
119 | ymax = {{ ymax }},
120 | yend = {{ yend }},
121 | z = {{ z }},
122 | col = {{ col }},
123 | facet = {{ facet }},
124 | facet2 = {{ facet2 }},
125 | group = {{ group }},
126 | subgroup = {{ subgroup }},
127 | label = {{ label }},
128 | text = {{ text }},
129 | sample = {{ sample }},
130 | mapping = mapping,
131 | x_breaks = x_breaks,
132 | x_expand = x_expand,
133 | x_limits_include = x_limits_include,
134 | x_labels = x_labels,
135 | x_breaks_n = x_breaks_n,
136 | x_sec_axis = x_sec_axis,
137 | x_symmetric = x_symmetric,
138 | x_position = x_position,
139 | x_label = x_label,
140 | x_transform = x_transform,
141 | y_breaks = y_breaks,
142 | y_expand = y_expand,
143 | y_limits_include = y_limits_include,
144 | y_labels = y_labels,
145 | y_breaks_n = y_breaks_n,
146 | y_sec_axis = y_sec_axis,
147 | y_symmetric = y_symmetric,
148 | y_position = y_position,
149 | y_label = y_label,
150 | y_transform = y_transform,
151 | col_breaks = col_breaks,
152 | col_drop = col_drop,
153 | col_limits_include = col_limits_include,
154 | col_labels = col_labels,
155 | col_legend_ncol = col_legend_ncol,
156 | col_legend_nrow = col_legend_nrow,
157 | col_legend_rev = col_legend_rev,
158 | col_breaks_n = col_breaks_n,
159 | col_palette = col_palette,
160 | col_palette_na = col_palette_na,
161 | col_rescale = col_rescale,
162 | col_steps = col_steps,
163 | col_label = col_label,
164 | col_transform = col_transform,
165 | facet_axes = facet_axes,
166 | facet_axis_labels = facet_axis_labels,
167 | facet_drop = facet_drop,
168 | facet_labels = facet_labels,
169 | facet_layout = facet_layout,
170 | facet_ncol = facet_ncol,
171 | facet_nrow = facet_nrow,
172 | facet_scales = facet_scales,
173 | facet_space = facet_space,
174 | title = title,
175 | subtitle = subtitle,
176 | caption = caption,
177 | label_case = label_case,
178 | ...
179 | )
180 | }
181 |
--------------------------------------------------------------------------------
/R/gg_bar.R:
--------------------------------------------------------------------------------
1 | #' Bar ggplot
2 | #'
3 | #' @description Create a bar ggplot with a wrapper around [ggplot2::ggplot()] + [geom_bar()][ggplot2::geom_bar()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_bar(
19 | #' y = species,
20 | #' width = 0.75,
21 | #' )
22 | #'
23 | gg_bar <- function(
24 | data = NULL,
25 | ...,
26 | stat = "count",
27 | position = "stack",
28 | coord = ggplot2::coord_cartesian(clip = "off"),
29 | theme = NULL,
30 | theme_orientation = NULL,
31 | theme_axis_line_rm = NULL,
32 | theme_axis_ticks_rm = NULL,
33 | theme_panel_grid_rm = NULL,
34 | blend = NULL,
35 | x = NULL,
36 | xmin = NULL,
37 | xmax = NULL,
38 | xend = NULL,
39 | y = NULL,
40 | ymin = NULL,
41 | ymax = NULL,
42 | yend = NULL,
43 | z = NULL,
44 | col = NULL,
45 | facet = NULL,
46 | facet2 = NULL,
47 | group = NULL,
48 | subgroup = NULL,
49 | label = NULL,
50 | text = NULL,
51 | sample = NULL,
52 | mapping = NULL,
53 | x_breaks = NULL,
54 | x_breaks_n = NULL,
55 | x_expand = NULL,
56 | x_limits_include = NULL,
57 | x_label = NULL,
58 | x_labels = NULL,
59 | x_position = "bottom",
60 | x_sec_axis = ggplot2::waiver(),
61 | x_symmetric = NULL,
62 | x_transform = NULL,
63 | y_breaks = NULL,
64 | y_breaks_n = NULL,
65 | y_expand = NULL,
66 | y_limits_include = NULL,
67 | y_label = NULL,
68 | y_labels = NULL,
69 | y_position = "left",
70 | y_sec_axis = ggplot2::waiver(),
71 | y_symmetric = NULL,
72 | y_transform = NULL,
73 | col_breaks = NULL,
74 | col_breaks_n = 5,
75 | col_drop = FALSE,
76 | col_limits_include = NULL,
77 | col_label = NULL,
78 | col_labels = NULL,
79 | col_legend_ncol = NULL,
80 | col_legend_nrow = NULL,
81 | col_legend_rev = FALSE,
82 | col_palette = NULL,
83 | col_palette_na = NULL,
84 | col_rescale = scales::rescale(),
85 | col_steps = FALSE,
86 | col_transform = NULL,
87 | facet_axes = NULL,
88 | facet_axis_labels = "margins",
89 | facet_drop = FALSE,
90 | facet_labels = NULL,
91 | facet_layout = NULL,
92 | facet_ncol = NULL,
93 | facet_nrow = NULL,
94 | facet_scales = "fixed",
95 | facet_space = "fixed",
96 | title = NULL,
97 | subtitle = NULL,
98 | caption = NULL,
99 | label_case = NULL
100 | ) {
101 | gg_blanket(
102 | data = data,
103 | geom = "bar",
104 | stat = stat,
105 | position = position,
106 | coord = coord,
107 | theme = theme,
108 | theme_orientation = theme_orientation,
109 | theme_axis_line_rm = theme_axis_line_rm,
110 | theme_axis_ticks_rm = theme_axis_ticks_rm,
111 | theme_panel_grid_rm = theme_panel_grid_rm,
112 | blend = blend,
113 | x = {{ x }},
114 | y = {{ y }},
115 | xmin = {{ xmin }},
116 | xmax = {{ xmax }},
117 | xend = {{ xend }},
118 | ymin = {{ ymin }},
119 | ymax = {{ ymax }},
120 | yend = {{ yend }},
121 | z = {{ z }},
122 | col = {{ col }},
123 | facet = {{ facet }},
124 | facet2 = {{ facet2 }},
125 | group = {{ group }},
126 | subgroup = {{ subgroup }},
127 | label = {{ label }},
128 | text = {{ text }},
129 | sample = {{ sample }},
130 | mapping = mapping,
131 | x_breaks = x_breaks,
132 | x_expand = x_expand,
133 | x_limits_include = x_limits_include,
134 | x_labels = x_labels,
135 | x_breaks_n = x_breaks_n,
136 | x_sec_axis = x_sec_axis,
137 | x_symmetric = x_symmetric,
138 | x_position = x_position,
139 | x_label = x_label,
140 | x_transform = x_transform,
141 | y_breaks = y_breaks,
142 | y_expand = y_expand,
143 | y_limits_include = y_limits_include,
144 | y_labels = y_labels,
145 | y_breaks_n = y_breaks_n,
146 | y_sec_axis = y_sec_axis,
147 | y_symmetric = y_symmetric,
148 | y_position = y_position,
149 | y_label = y_label,
150 | y_transform = y_transform,
151 | col_breaks = col_breaks,
152 | col_drop = col_drop,
153 | col_limits_include = col_limits_include,
154 | col_labels = col_labels,
155 | col_legend_ncol = col_legend_ncol,
156 | col_legend_nrow = col_legend_nrow,
157 | col_legend_rev = col_legend_rev,
158 | col_breaks_n = col_breaks_n,
159 | col_palette = col_palette,
160 | col_palette_na = col_palette_na,
161 | col_rescale = col_rescale,
162 | col_steps = col_steps,
163 | col_label = col_label,
164 | col_transform = col_transform,
165 | facet_axes = facet_axes,
166 | facet_axis_labels = facet_axis_labels,
167 | facet_drop = facet_drop,
168 | facet_labels = facet_labels,
169 | facet_layout = facet_layout,
170 | facet_ncol = facet_ncol,
171 | facet_nrow = facet_nrow,
172 | facet_scales = facet_scales,
173 | facet_space = facet_space,
174 | title = title,
175 | subtitle = subtitle,
176 | caption = caption,
177 | label_case = label_case,
178 | ...
179 | )
180 | }
181 |
--------------------------------------------------------------------------------
/R/gg_area.R:
--------------------------------------------------------------------------------
1 | #' Area ggplot
2 | #'
3 | #' @description Create an area ggplot with a wrapper around [ggplot2::ggplot()] + [geom_area()][ggplot2::geom_area()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' economics |>
17 | #' gg_area(
18 | #' x = date,
19 | #' y = unemploy,
20 | #' y_label = "Unemployment",
21 | #' )
22 | #'
23 | gg_area <- function(
24 | data = NULL,
25 | ...,
26 | stat = "align",
27 | position = "stack",
28 | coord = ggplot2::coord_cartesian(clip = "off"),
29 | theme = NULL,
30 | theme_orientation = NULL,
31 | theme_axis_line_rm = NULL,
32 | theme_axis_ticks_rm = NULL,
33 | theme_panel_grid_rm = NULL,
34 | blend = NULL,
35 | x = NULL,
36 | xmin = NULL,
37 | xmax = NULL,
38 | xend = NULL,
39 | y = NULL,
40 | ymin = NULL,
41 | ymax = NULL,
42 | yend = NULL,
43 | z = NULL,
44 | col = NULL,
45 | facet = NULL,
46 | facet2 = NULL,
47 | group = NULL,
48 | subgroup = NULL,
49 | label = NULL,
50 | text = NULL,
51 | sample = NULL,
52 | mapping = NULL,
53 | x_breaks = NULL,
54 | x_breaks_n = NULL,
55 | x_expand = NULL,
56 | x_limits_include = NULL,
57 | x_label = NULL,
58 | x_labels = NULL,
59 | x_position = "bottom",
60 | x_sec_axis = ggplot2::waiver(),
61 | x_symmetric = NULL,
62 | x_transform = NULL,
63 | y_breaks = NULL,
64 | y_breaks_n = NULL,
65 | y_expand = NULL,
66 | y_limits_include = NULL,
67 | y_label = NULL,
68 | y_labels = NULL,
69 | y_position = "left",
70 | y_sec_axis = ggplot2::waiver(),
71 | y_symmetric = NULL,
72 | y_transform = NULL,
73 | col_breaks = NULL,
74 | col_breaks_n = 5,
75 | col_drop = FALSE,
76 | col_limits_include = NULL,
77 | col_label = NULL,
78 | col_labels = NULL,
79 | col_legend_ncol = NULL,
80 | col_legend_nrow = NULL,
81 | col_legend_rev = FALSE,
82 | col_palette = NULL,
83 | col_palette_na = NULL,
84 | col_rescale = scales::rescale(),
85 | col_steps = FALSE,
86 | col_transform = NULL,
87 | facet_axes = NULL,
88 | facet_axis_labels = "margins",
89 | facet_drop = FALSE,
90 | facet_labels = NULL,
91 | facet_layout = NULL,
92 | facet_ncol = NULL,
93 | facet_nrow = NULL,
94 | facet_scales = "fixed",
95 | facet_space = "fixed",
96 | title = NULL,
97 | subtitle = NULL,
98 | caption = NULL,
99 | label_case = NULL
100 | ) {
101 | gg_blanket(
102 | data = data,
103 | geom = "area",
104 | stat = stat,
105 | position = position,
106 | coord = coord,
107 | theme = theme,
108 | theme_orientation = theme_orientation,
109 | theme_axis_line_rm = theme_axis_line_rm,
110 | theme_axis_ticks_rm = theme_axis_ticks_rm,
111 | theme_panel_grid_rm = theme_panel_grid_rm,
112 | blend = blend,
113 | x = {{ x }},
114 | y = {{ y }},
115 | xmin = {{ xmin }},
116 | xmax = {{ xmax }},
117 | xend = {{ xend }},
118 | ymin = {{ ymin }},
119 | ymax = {{ ymax }},
120 | yend = {{ yend }},
121 | z = {{ z }},
122 | col = {{ col }},
123 | facet = {{ facet }},
124 | facet2 = {{ facet2 }},
125 | group = {{ group }},
126 | subgroup = {{ subgroup }},
127 | label = {{ label }},
128 | text = {{ text }},
129 | sample = {{ sample }},
130 | mapping = mapping,
131 | x_breaks = x_breaks,
132 | x_expand = x_expand,
133 | x_limits_include = x_limits_include,
134 | x_labels = x_labels,
135 | x_breaks_n = x_breaks_n,
136 | x_sec_axis = x_sec_axis,
137 | x_symmetric = x_symmetric,
138 | x_position = x_position,
139 | x_label = x_label,
140 | x_transform = x_transform,
141 | y_breaks = y_breaks,
142 | y_expand = y_expand,
143 | y_limits_include = y_limits_include,
144 | y_labels = y_labels,
145 | y_breaks_n = y_breaks_n,
146 | y_sec_axis = y_sec_axis,
147 | y_symmetric = y_symmetric,
148 | y_position = y_position,
149 | y_label = y_label,
150 | y_transform = y_transform,
151 | col_breaks = col_breaks,
152 | col_drop = col_drop,
153 | col_limits_include = col_limits_include,
154 | col_labels = col_labels,
155 | col_legend_ncol = col_legend_ncol,
156 | col_legend_nrow = col_legend_nrow,
157 | col_legend_rev = col_legend_rev,
158 | col_breaks_n = col_breaks_n,
159 | col_palette = col_palette,
160 | col_palette_na = col_palette_na,
161 | col_rescale = col_rescale,
162 | col_steps = col_steps,
163 | col_label = col_label,
164 | col_transform = col_transform,
165 | facet_axes = facet_axes,
166 | facet_axis_labels = facet_axis_labels,
167 | facet_drop = facet_drop,
168 | facet_labels = facet_labels,
169 | facet_layout = facet_layout,
170 | facet_ncol = facet_ncol,
171 | facet_nrow = facet_nrow,
172 | facet_scales = facet_scales,
173 | facet_space = facet_space,
174 | title = title,
175 | subtitle = subtitle,
176 | caption = caption,
177 | label_case = label_case,
178 | ...
179 | )
180 | }
181 |
--------------------------------------------------------------------------------
/R/gg_bin_2d.R:
--------------------------------------------------------------------------------
1 | #' Bin_2d ggplot
2 | #'
3 | #' @description Create a bin2d ggplot with a wrapper around [ggplot2::ggplot()] + [geom_bin_2d()][ggplot2::geom_bin_2d()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' diamonds |>
17 | #' gg_bin_2d(
18 | #' x = carat,
19 | #' y = price,
20 | #' coord = coord_cartesian(),
21 | #' )
22 | #'
23 | gg_bin_2d <- function(
24 | data = NULL,
25 | ...,
26 | stat = "bin2d",
27 | position = "identity",
28 | coord = ggplot2::coord_cartesian(clip = "off"),
29 | theme = NULL,
30 | theme_orientation = NULL,
31 | theme_axis_line_rm = NULL,
32 | theme_axis_ticks_rm = NULL,
33 | theme_panel_grid_rm = NULL,
34 | blend = NULL,
35 | x = NULL,
36 | xmin = NULL,
37 | xmax = NULL,
38 | xend = NULL,
39 | y = NULL,
40 | ymin = NULL,
41 | ymax = NULL,
42 | yend = NULL,
43 | z = NULL,
44 | col = NULL,
45 | facet = NULL,
46 | facet2 = NULL,
47 | group = NULL,
48 | subgroup = NULL,
49 | label = NULL,
50 | text = NULL,
51 | sample = NULL,
52 | mapping = NULL,
53 | x_breaks = NULL,
54 | x_breaks_n = NULL,
55 | x_expand = NULL,
56 | x_limits_include = NULL,
57 | x_label = NULL,
58 | x_labels = NULL,
59 | x_position = "bottom",
60 | x_sec_axis = ggplot2::waiver(),
61 | x_symmetric = NULL,
62 | x_transform = NULL,
63 | y_breaks = NULL,
64 | y_breaks_n = NULL,
65 | y_expand = NULL,
66 | y_limits_include = NULL,
67 | y_label = NULL,
68 | y_labels = NULL,
69 | y_position = "left",
70 | y_sec_axis = ggplot2::waiver(),
71 | y_symmetric = NULL,
72 | y_transform = NULL,
73 | col_breaks = NULL,
74 | col_breaks_n = 5,
75 | col_drop = FALSE,
76 | col_limits_include = NULL,
77 | col_label = NULL,
78 | col_labels = NULL,
79 | col_legend_ncol = NULL,
80 | col_legend_nrow = NULL,
81 | col_legend_rev = FALSE,
82 | col_palette = NULL,
83 | col_palette_na = NULL,
84 | col_rescale = scales::rescale(),
85 | col_steps = FALSE,
86 | col_transform = NULL,
87 | facet_axes = NULL,
88 | facet_axis_labels = "margins",
89 | facet_drop = FALSE,
90 | facet_labels = NULL,
91 | facet_layout = NULL,
92 | facet_ncol = NULL,
93 | facet_nrow = NULL,
94 | facet_scales = "fixed",
95 | facet_space = "fixed",
96 | title = NULL,
97 | subtitle = NULL,
98 | caption = NULL,
99 | label_case = NULL
100 | ) {
101 | gg_blanket(
102 | data = data,
103 | geom = "tile",
104 | stat = stat,
105 | position = position,
106 | coord = coord,
107 | theme = theme,
108 | theme_orientation = theme_orientation,
109 | theme_axis_line_rm = theme_axis_line_rm,
110 | theme_axis_ticks_rm = theme_axis_ticks_rm,
111 | theme_panel_grid_rm = theme_panel_grid_rm,
112 | blend = blend,
113 | x = {{ x }},
114 | y = {{ y }},
115 | xmin = {{ xmin }},
116 | xmax = {{ xmax }},
117 | xend = {{ xend }},
118 | ymin = {{ ymin }},
119 | ymax = {{ ymax }},
120 | yend = {{ yend }},
121 | z = {{ z }},
122 | col = {{ col }},
123 | facet = {{ facet }},
124 | facet2 = {{ facet2 }},
125 | group = {{ group }},
126 | subgroup = {{ subgroup }},
127 | label = {{ label }},
128 | text = {{ text }},
129 | sample = {{ sample }},
130 | mapping = mapping,
131 | x_breaks = x_breaks,
132 | x_expand = x_expand,
133 | x_limits_include = x_limits_include,
134 | x_labels = x_labels,
135 | x_breaks_n = x_breaks_n,
136 | x_sec_axis = x_sec_axis,
137 | x_symmetric = x_symmetric,
138 | x_position = x_position,
139 | x_label = x_label,
140 | x_transform = x_transform,
141 | y_breaks = y_breaks,
142 | y_expand = y_expand,
143 | y_limits_include = y_limits_include,
144 | y_labels = y_labels,
145 | y_breaks_n = y_breaks_n,
146 | y_sec_axis = y_sec_axis,
147 | y_symmetric = y_symmetric,
148 | y_position = y_position,
149 | y_label = y_label,
150 | y_transform = y_transform,
151 | col_breaks = col_breaks,
152 | col_drop = col_drop,
153 | col_limits_include = col_limits_include,
154 | col_labels = col_labels,
155 | col_legend_ncol = col_legend_ncol,
156 | col_legend_nrow = col_legend_nrow,
157 | col_legend_rev = col_legend_rev,
158 | col_breaks_n = col_breaks_n,
159 | col_palette = col_palette,
160 | col_palette_na = col_palette_na,
161 | col_rescale = col_rescale,
162 | col_steps = col_steps,
163 | col_label = col_label,
164 | col_transform = col_transform,
165 | facet_axes = facet_axes,
166 | facet_axis_labels = facet_axis_labels,
167 | facet_drop = facet_drop,
168 | facet_labels = facet_labels,
169 | facet_layout = facet_layout,
170 | facet_ncol = facet_ncol,
171 | facet_nrow = facet_nrow,
172 | facet_scales = facet_scales,
173 | facet_space = facet_space,
174 | title = title,
175 | subtitle = subtitle,
176 | caption = caption,
177 | label_case = label_case,
178 | ...
179 | )
180 | }
181 |
--------------------------------------------------------------------------------
/R/gg_raster.R:
--------------------------------------------------------------------------------
1 | #' Raster ggplot
2 | #'
3 | #' @description Create a raster ggplot with a wrapper around [ggplot2::ggplot()] + [geom_raster()][ggplot2::geom_raster()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' faithfuld |>
17 | #' gg_raster(
18 | #' x = waiting,
19 | #' y = eruptions,
20 | #' col = density,
21 | #' )
22 | #'
23 | gg_raster <- function(
24 | data = NULL,
25 | ...,
26 | stat = "identity",
27 | position = "identity",
28 | coord = ggplot2::coord_cartesian(clip = "off"),
29 | theme = NULL,
30 | theme_orientation = NULL,
31 | theme_axis_line_rm = NULL,
32 | theme_axis_ticks_rm = NULL,
33 | theme_panel_grid_rm = NULL,
34 | blend = NULL,
35 | x = NULL,
36 | xmin = NULL,
37 | xmax = NULL,
38 | xend = NULL,
39 | y = NULL,
40 | ymin = NULL,
41 | ymax = NULL,
42 | yend = NULL,
43 | z = NULL,
44 | col = NULL,
45 | facet = NULL,
46 | facet2 = NULL,
47 | group = NULL,
48 | subgroup = NULL,
49 | label = NULL,
50 | text = NULL,
51 | sample = NULL,
52 | mapping = NULL,
53 | x_breaks = NULL,
54 | x_breaks_n = NULL,
55 | x_expand = NULL,
56 | x_limits_include = NULL,
57 | x_label = NULL,
58 | x_labels = NULL,
59 | x_position = "bottom",
60 | x_sec_axis = ggplot2::waiver(),
61 | x_symmetric = NULL,
62 | x_transform = NULL,
63 | y_breaks = NULL,
64 | y_breaks_n = NULL,
65 | y_expand = NULL,
66 | y_limits_include = NULL,
67 | y_label = NULL,
68 | y_labels = NULL,
69 | y_position = "left",
70 | y_sec_axis = ggplot2::waiver(),
71 | y_symmetric = NULL,
72 | y_transform = NULL,
73 | col_breaks = NULL,
74 | col_breaks_n = 5,
75 | col_drop = FALSE,
76 | col_limits_include = NULL,
77 | col_label = NULL,
78 | col_labels = NULL,
79 | col_legend_ncol = NULL,
80 | col_legend_nrow = NULL,
81 | col_legend_rev = FALSE,
82 | col_palette = NULL,
83 | col_palette_na = NULL,
84 | col_rescale = scales::rescale(),
85 | col_steps = FALSE,
86 | col_transform = NULL,
87 | facet_axes = NULL,
88 | facet_axis_labels = "margins",
89 | facet_drop = FALSE,
90 | facet_labels = NULL,
91 | facet_layout = NULL,
92 | facet_ncol = NULL,
93 | facet_nrow = NULL,
94 | facet_scales = "fixed",
95 | facet_space = "fixed",
96 | title = NULL,
97 | subtitle = NULL,
98 | caption = NULL,
99 | label_case = NULL
100 | ) {
101 | gg_blanket(
102 | data = data,
103 | geom = "raster",
104 | stat = stat,
105 | position = position,
106 | coord = coord,
107 | theme = theme,
108 | theme_orientation = theme_orientation,
109 | theme_axis_line_rm = theme_axis_line_rm,
110 | theme_axis_ticks_rm = theme_axis_ticks_rm,
111 | theme_panel_grid_rm = theme_panel_grid_rm,
112 | blend = blend,
113 | x = {{ x }},
114 | y = {{ y }},
115 | xmin = {{ xmin }},
116 | xmax = {{ xmax }},
117 | xend = {{ xend }},
118 | ymin = {{ ymin }},
119 | ymax = {{ ymax }},
120 | yend = {{ yend }},
121 | z = {{ z }},
122 | col = {{ col }},
123 | facet = {{ facet }},
124 | facet2 = {{ facet2 }},
125 | group = {{ group }},
126 | subgroup = {{ subgroup }},
127 | label = {{ label }},
128 | text = {{ text }},
129 | sample = {{ sample }},
130 | mapping = mapping,
131 | x_breaks = x_breaks,
132 | x_expand = x_expand,
133 | x_limits_include = x_limits_include,
134 | x_labels = x_labels,
135 | x_breaks_n = x_breaks_n,
136 | x_sec_axis = x_sec_axis,
137 | x_symmetric = x_symmetric,
138 | x_position = x_position,
139 | x_label = x_label,
140 | x_transform = x_transform,
141 | y_breaks = y_breaks,
142 | y_expand = y_expand,
143 | y_limits_include = y_limits_include,
144 | y_labels = y_labels,
145 | y_breaks_n = y_breaks_n,
146 | y_sec_axis = y_sec_axis,
147 | y_symmetric = y_symmetric,
148 | y_position = y_position,
149 | y_label = y_label,
150 | y_transform = y_transform,
151 | col_breaks = col_breaks,
152 | col_drop = col_drop,
153 | col_limits_include = col_limits_include,
154 | col_labels = col_labels,
155 | col_legend_ncol = col_legend_ncol,
156 | col_legend_nrow = col_legend_nrow,
157 | col_legend_rev = col_legend_rev,
158 | col_breaks_n = col_breaks_n,
159 | col_palette = col_palette,
160 | col_palette_na = col_palette_na,
161 | col_rescale = col_rescale,
162 | col_steps = col_steps,
163 | col_label = col_label,
164 | col_transform = col_transform,
165 | facet_axes = facet_axes,
166 | facet_axis_labels = facet_axis_labels,
167 | facet_drop = facet_drop,
168 | facet_labels = facet_labels,
169 | facet_layout = facet_layout,
170 | facet_ncol = facet_ncol,
171 | facet_nrow = facet_nrow,
172 | facet_scales = facet_scales,
173 | facet_space = facet_space,
174 | title = title,
175 | subtitle = subtitle,
176 | caption = caption,
177 | label_case = label_case,
178 | ...
179 | )
180 | }
181 |
--------------------------------------------------------------------------------
/R/gg_contour.R:
--------------------------------------------------------------------------------
1 | #' Contour ggplot
2 | #'
3 | #' @description Create a contour ggplot with a wrapper around [ggplot2::ggplot()] + [geom_contour()][ggplot2::geom_contour()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' ggplot2::faithfuld |>
17 | #' gg_contour(
18 | #' x = waiting,
19 | #' y = eruptions,
20 | #' z = density,
21 | #' )
22 | #'
23 | gg_contour <- function(
24 | data = NULL,
25 | ...,
26 | stat = "contour",
27 | position = "identity",
28 | coord = ggplot2::coord_cartesian(clip = "off"),
29 | theme = NULL,
30 | theme_orientation = NULL,
31 | theme_axis_line_rm = NULL,
32 | theme_axis_ticks_rm = NULL,
33 | theme_panel_grid_rm = NULL,
34 | blend = NULL,
35 | x = NULL,
36 | xmin = NULL,
37 | xmax = NULL,
38 | xend = NULL,
39 | y = NULL,
40 | ymin = NULL,
41 | ymax = NULL,
42 | yend = NULL,
43 | z = NULL,
44 | col = NULL,
45 | facet = NULL,
46 | facet2 = NULL,
47 | group = NULL,
48 | subgroup = NULL,
49 | label = NULL,
50 | text = NULL,
51 | sample = NULL,
52 | mapping = NULL,
53 | x_breaks = NULL,
54 | x_breaks_n = NULL,
55 | x_expand = NULL,
56 | x_limits_include = NULL,
57 | x_label = NULL,
58 | x_labels = NULL,
59 | x_position = "bottom",
60 | x_sec_axis = ggplot2::waiver(),
61 | x_symmetric = NULL,
62 | x_transform = NULL,
63 | y_breaks = NULL,
64 | y_breaks_n = NULL,
65 | y_expand = NULL,
66 | y_limits_include = NULL,
67 | y_label = NULL,
68 | y_labels = NULL,
69 | y_position = "left",
70 | y_sec_axis = ggplot2::waiver(),
71 | y_symmetric = NULL,
72 | y_transform = NULL,
73 | col_breaks = NULL,
74 | col_breaks_n = 5,
75 | col_drop = FALSE,
76 | col_limits_include = NULL,
77 | col_label = NULL,
78 | col_labels = NULL,
79 | col_legend_ncol = NULL,
80 | col_legend_nrow = NULL,
81 | col_legend_rev = FALSE,
82 | col_palette = NULL,
83 | col_palette_na = NULL,
84 | col_rescale = scales::rescale(),
85 | col_steps = FALSE,
86 | col_transform = NULL,
87 | facet_axes = NULL,
88 | facet_axis_labels = "margins",
89 | facet_drop = FALSE,
90 | facet_labels = NULL,
91 | facet_layout = NULL,
92 | facet_ncol = NULL,
93 | facet_nrow = NULL,
94 | facet_scales = "fixed",
95 | facet_space = "fixed",
96 | title = NULL,
97 | subtitle = NULL,
98 | caption = NULL,
99 | label_case = NULL
100 | ) {
101 | gg_blanket(
102 | data = data,
103 | geom = "contour",
104 | stat = stat,
105 | position = position,
106 | coord = coord,
107 | theme = theme,
108 | theme_orientation = theme_orientation,
109 | theme_axis_line_rm = theme_axis_line_rm,
110 | theme_axis_ticks_rm = theme_axis_ticks_rm,
111 | theme_panel_grid_rm = theme_panel_grid_rm,
112 | blend = blend,
113 | x = {{ x }},
114 | y = {{ y }},
115 | xmin = {{ xmin }},
116 | xmax = {{ xmax }},
117 | xend = {{ xend }},
118 | ymin = {{ ymin }},
119 | ymax = {{ ymax }},
120 | yend = {{ yend }},
121 | z = {{ z }},
122 | col = {{ col }},
123 | facet = {{ facet }},
124 | facet2 = {{ facet2 }},
125 | group = {{ group }},
126 | subgroup = {{ subgroup }},
127 | label = {{ label }},
128 | text = {{ text }},
129 | sample = {{ sample }},
130 | mapping = mapping,
131 | x_breaks = x_breaks,
132 | x_expand = x_expand,
133 | x_limits_include = x_limits_include,
134 | x_labels = x_labels,
135 | x_breaks_n = x_breaks_n,
136 | x_sec_axis = x_sec_axis,
137 | x_symmetric = x_symmetric,
138 | x_position = x_position,
139 | x_label = x_label,
140 | x_transform = x_transform,
141 | y_breaks = y_breaks,
142 | y_expand = y_expand,
143 | y_limits_include = y_limits_include,
144 | y_labels = y_labels,
145 | y_breaks_n = y_breaks_n,
146 | y_sec_axis = y_sec_axis,
147 | y_symmetric = y_symmetric,
148 | y_position = y_position,
149 | y_label = y_label,
150 | y_transform = y_transform,
151 | col_breaks = col_breaks,
152 | col_drop = col_drop,
153 | col_limits_include = col_limits_include,
154 | col_labels = col_labels,
155 | col_legend_ncol = col_legend_ncol,
156 | col_legend_nrow = col_legend_nrow,
157 | col_legend_rev = col_legend_rev,
158 | col_breaks_n = col_breaks_n,
159 | col_palette = col_palette,
160 | col_palette_na = col_palette_na,
161 | col_rescale = col_rescale,
162 | col_steps = col_steps,
163 | col_label = col_label,
164 | col_transform = col_transform,
165 | facet_axes = facet_axes,
166 | facet_axis_labels = facet_axis_labels,
167 | facet_drop = facet_drop,
168 | facet_labels = facet_labels,
169 | facet_layout = facet_layout,
170 | facet_ncol = facet_ncol,
171 | facet_nrow = facet_nrow,
172 | facet_scales = facet_scales,
173 | facet_space = facet_space,
174 | title = title,
175 | subtitle = subtitle,
176 | caption = caption,
177 | label_case = label_case,
178 | ...
179 | )
180 | }
181 |
--------------------------------------------------------------------------------
/R/gg_freqpoly.R:
--------------------------------------------------------------------------------
1 | #' Freqpoly ggplot
2 | #'
3 | #' @description Create a freqpoly ggplot with a wrapper around [ggplot2::ggplot()] + [geom_freqpoly()][ggplot2::geom_freqpoly()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_freqpoly(
19 | #' x = flipper_length_mm,
20 | #' col = sex,
21 | #' )
22 | #'
23 | gg_freqpoly <- function(
24 | data = NULL,
25 | ...,
26 | stat = "bin",
27 | position = "identity",
28 | coord = ggplot2::coord_cartesian(clip = "off"),
29 | theme = NULL,
30 | theme_orientation = NULL,
31 | theme_axis_line_rm = NULL,
32 | theme_axis_ticks_rm = NULL,
33 | theme_panel_grid_rm = NULL,
34 | blend = NULL,
35 | x = NULL,
36 | xmin = NULL,
37 | xmax = NULL,
38 | xend = NULL,
39 | y = NULL,
40 | ymin = NULL,
41 | ymax = NULL,
42 | yend = NULL,
43 | z = NULL,
44 | col = NULL,
45 | facet = NULL,
46 | facet2 = NULL,
47 | group = NULL,
48 | subgroup = NULL,
49 | label = NULL,
50 | text = NULL,
51 | sample = NULL,
52 | mapping = NULL,
53 | x_breaks = NULL,
54 | x_breaks_n = NULL,
55 | x_expand = NULL,
56 | x_limits_include = NULL,
57 | x_label = NULL,
58 | x_labels = NULL,
59 | x_position = "bottom",
60 | x_sec_axis = ggplot2::waiver(),
61 | x_symmetric = NULL,
62 | x_transform = NULL,
63 | y_breaks = NULL,
64 | y_breaks_n = NULL,
65 | y_expand = NULL,
66 | y_limits_include = NULL,
67 | y_label = NULL,
68 | y_labels = NULL,
69 | y_position = "left",
70 | y_sec_axis = ggplot2::waiver(),
71 | y_symmetric = NULL,
72 | y_transform = NULL,
73 | col_breaks = NULL,
74 | col_breaks_n = 5,
75 | col_drop = FALSE,
76 | col_limits_include = NULL,
77 | col_label = NULL,
78 | col_labels = NULL,
79 | col_legend_ncol = NULL,
80 | col_legend_nrow = NULL,
81 | col_legend_rev = FALSE,
82 | col_palette = NULL,
83 | col_palette_na = NULL,
84 | col_rescale = scales::rescale(),
85 | col_steps = FALSE,
86 | col_transform = NULL,
87 | facet_axes = NULL,
88 | facet_axis_labels = "margins",
89 | facet_drop = FALSE,
90 | facet_labels = NULL,
91 | facet_layout = NULL,
92 | facet_ncol = NULL,
93 | facet_nrow = NULL,
94 | facet_scales = "fixed",
95 | facet_space = "fixed",
96 | title = NULL,
97 | subtitle = NULL,
98 | caption = NULL,
99 | label_case = NULL
100 | ) {
101 | gg_blanket(
102 | data = data,
103 | geom = "line",
104 | stat = stat,
105 | position = position,
106 | coord = coord,
107 | theme = theme,
108 | theme_orientation = theme_orientation,
109 | theme_axis_line_rm = theme_axis_line_rm,
110 | theme_axis_ticks_rm = theme_axis_ticks_rm,
111 | theme_panel_grid_rm = theme_panel_grid_rm,
112 | blend = blend,
113 | x = {{ x }},
114 | y = {{ y }},
115 | xmin = {{ xmin }},
116 | xmax = {{ xmax }},
117 | xend = {{ xend }},
118 | ymin = {{ ymin }},
119 | ymax = {{ ymax }},
120 | yend = {{ yend }},
121 | z = {{ z }},
122 | col = {{ col }},
123 | facet = {{ facet }},
124 | facet2 = {{ facet2 }},
125 | group = {{ group }},
126 | subgroup = {{ subgroup }},
127 | label = {{ label }},
128 | text = {{ text }},
129 | sample = {{ sample }},
130 | mapping = mapping,
131 | x_breaks = x_breaks,
132 | x_expand = x_expand,
133 | x_limits_include = x_limits_include,
134 | x_labels = x_labels,
135 | x_breaks_n = x_breaks_n,
136 | x_sec_axis = x_sec_axis,
137 | x_symmetric = x_symmetric,
138 | x_position = x_position,
139 | x_label = x_label,
140 | x_transform = x_transform,
141 | y_breaks = y_breaks,
142 | y_expand = y_expand,
143 | y_limits_include = y_limits_include,
144 | y_labels = y_labels,
145 | y_breaks_n = y_breaks_n,
146 | y_sec_axis = y_sec_axis,
147 | y_symmetric = y_symmetric,
148 | y_position = y_position,
149 | y_label = y_label,
150 | y_transform = y_transform,
151 | col_breaks = col_breaks,
152 | col_drop = col_drop,
153 | col_limits_include = col_limits_include,
154 | col_labels = col_labels,
155 | col_legend_ncol = col_legend_ncol,
156 | col_legend_nrow = col_legend_nrow,
157 | col_legend_rev = col_legend_rev,
158 | col_breaks_n = col_breaks_n,
159 | col_palette = col_palette,
160 | col_palette_na = col_palette_na,
161 | col_rescale = col_rescale,
162 | col_steps = col_steps,
163 | col_label = col_label,
164 | col_transform = col_transform,
165 | facet_axes = facet_axes,
166 | facet_axis_labels = facet_axis_labels,
167 | facet_drop = facet_drop,
168 | facet_labels = facet_labels,
169 | facet_layout = facet_layout,
170 | facet_ncol = facet_ncol,
171 | facet_nrow = facet_nrow,
172 | facet_scales = facet_scales,
173 | facet_space = facet_space,
174 | title = title,
175 | subtitle = subtitle,
176 | caption = caption,
177 | label_case = label_case,
178 | ...
179 | )
180 | }
181 |
--------------------------------------------------------------------------------
/R/gg_rug.R:
--------------------------------------------------------------------------------
1 | #' Rug ggplot
2 | #'
3 | #' @description Create a rug ggplot with a wrapper around [ggplot2::ggplot()] + [geom_rug()][ggplot2::geom_rug()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_rug(
19 | #' x = flipper_length_mm,
20 | #' y = body_mass_g,
21 | #' col = species,
22 | #' )
23 | #'
24 | gg_rug <- function(
25 | data = NULL,
26 | ...,
27 | stat = "identity",
28 | position = "identity",
29 | coord = ggplot2::coord_cartesian(clip = "off"),
30 | theme = NULL,
31 | theme_orientation = NULL,
32 | theme_axis_line_rm = NULL,
33 | theme_axis_ticks_rm = NULL,
34 | theme_panel_grid_rm = NULL,
35 | blend = NULL,
36 | x = NULL,
37 | xmin = NULL,
38 | xmax = NULL,
39 | xend = NULL,
40 | y = NULL,
41 | ymin = NULL,
42 | ymax = NULL,
43 | yend = NULL,
44 | z = NULL,
45 | col = NULL,
46 | facet = NULL,
47 | facet2 = NULL,
48 | group = NULL,
49 | subgroup = NULL,
50 | label = NULL,
51 | text = NULL,
52 | sample = NULL,
53 | mapping = NULL,
54 | x_breaks = NULL,
55 | x_breaks_n = NULL,
56 | x_expand = NULL,
57 | x_limits_include = NULL,
58 | x_label = NULL,
59 | x_labels = NULL,
60 | x_position = "bottom",
61 | x_sec_axis = ggplot2::waiver(),
62 | x_symmetric = NULL,
63 | x_transform = NULL,
64 | y_breaks = NULL,
65 | y_breaks_n = NULL,
66 | y_expand = NULL,
67 | y_limits_include = NULL,
68 | y_label = NULL,
69 | y_labels = NULL,
70 | y_position = "left",
71 | y_sec_axis = ggplot2::waiver(),
72 | y_symmetric = NULL,
73 | y_transform = NULL,
74 | col_breaks = NULL,
75 | col_breaks_n = 5,
76 | col_drop = FALSE,
77 | col_limits_include = NULL,
78 | col_label = NULL,
79 | col_labels = NULL,
80 | col_legend_ncol = NULL,
81 | col_legend_nrow = NULL,
82 | col_legend_rev = FALSE,
83 | col_palette = NULL,
84 | col_palette_na = NULL,
85 | col_rescale = scales::rescale(),
86 | col_steps = FALSE,
87 | col_transform = NULL,
88 | facet_axes = NULL,
89 | facet_axis_labels = "margins",
90 | facet_drop = FALSE,
91 | facet_labels = NULL,
92 | facet_layout = NULL,
93 | facet_ncol = NULL,
94 | facet_nrow = NULL,
95 | facet_scales = "fixed",
96 | facet_space = "fixed",
97 | title = NULL,
98 | subtitle = NULL,
99 | caption = NULL,
100 | label_case = NULL
101 | ) {
102 | gg_blanket(
103 | data = data,
104 | geom = "rug",
105 | stat = stat,
106 | position = position,
107 | coord = coord,
108 | theme = theme,
109 | theme_orientation = theme_orientation,
110 | theme_axis_line_rm = theme_axis_line_rm,
111 | theme_axis_ticks_rm = theme_axis_ticks_rm,
112 | theme_panel_grid_rm = theme_panel_grid_rm,
113 | blend = blend,
114 | x = {{ x }},
115 | y = {{ y }},
116 | xmin = {{ xmin }},
117 | xmax = {{ xmax }},
118 | xend = {{ xend }},
119 | ymin = {{ ymin }},
120 | ymax = {{ ymax }},
121 | yend = {{ yend }},
122 | z = {{ z }},
123 | col = {{ col }},
124 | facet = {{ facet }},
125 | facet2 = {{ facet2 }},
126 | group = {{ group }},
127 | subgroup = {{ subgroup }},
128 | label = {{ label }},
129 | text = {{ text }},
130 | sample = {{ sample }},
131 | mapping = mapping,
132 | x_breaks = x_breaks,
133 | x_expand = x_expand,
134 | x_limits_include = x_limits_include,
135 | x_labels = x_labels,
136 | x_breaks_n = x_breaks_n,
137 | x_sec_axis = x_sec_axis,
138 | x_symmetric = x_symmetric,
139 | x_position = x_position,
140 | x_label = x_label,
141 | x_transform = x_transform,
142 | y_breaks = y_breaks,
143 | y_expand = y_expand,
144 | y_limits_include = y_limits_include,
145 | y_labels = y_labels,
146 | y_breaks_n = y_breaks_n,
147 | y_sec_axis = y_sec_axis,
148 | y_symmetric = y_symmetric,
149 | y_position = y_position,
150 | y_label = y_label,
151 | y_transform = y_transform,
152 | col_breaks = col_breaks,
153 | col_drop = col_drop,
154 | col_limits_include = col_limits_include,
155 | col_labels = col_labels,
156 | col_legend_ncol = col_legend_ncol,
157 | col_legend_nrow = col_legend_nrow,
158 | col_legend_rev = col_legend_rev,
159 | col_breaks_n = col_breaks_n,
160 | col_palette = col_palette,
161 | col_palette_na = col_palette_na,
162 | col_rescale = col_rescale,
163 | col_steps = col_steps,
164 | col_label = col_label,
165 | col_transform = col_transform,
166 | facet_axes = facet_axes,
167 | facet_axis_labels = facet_axis_labels,
168 | facet_drop = facet_drop,
169 | facet_labels = facet_labels,
170 | facet_layout = facet_layout,
171 | facet_ncol = facet_ncol,
172 | facet_nrow = facet_nrow,
173 | facet_scales = facet_scales,
174 | facet_space = facet_space,
175 | title = title,
176 | subtitle = subtitle,
177 | caption = caption,
178 | label_case = label_case,
179 | ...
180 | )
181 | }
182 |
--------------------------------------------------------------------------------
/R/gg_sf.R:
--------------------------------------------------------------------------------
1 | #' Sf ggplot
2 | #'
3 | #' @description Create a blank ggplot with a wrapper around [ggplot2::ggplot()] + [geom_sf()][ggplot2::geom_sf()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' if (requireNamespace("sf", quietly = TRUE)) {
17 | #' sf::st_read(system.file("shape/nc.shp", package = "sf")) |>
18 | #' gg_sf(
19 | #' col = AREA,
20 | #' )
21 | #' }
22 | #'
23 | gg_sf <- function(
24 | data = NULL,
25 | ...,
26 | stat = "sf",
27 | position = "identity",
28 | coord = ggplot2::coord_sf(clip = "off"),
29 | theme = NULL,
30 | theme_orientation = NULL,
31 | theme_axis_line_rm = NULL,
32 | theme_axis_ticks_rm = NULL,
33 | theme_panel_grid_rm = NULL,
34 | blend = NULL,
35 | x = NULL,
36 | xmin = NULL,
37 | xmax = NULL,
38 | xend = NULL,
39 | y = NULL,
40 | ymin = NULL,
41 | ymax = NULL,
42 | yend = NULL,
43 | z = NULL,
44 | col = NULL,
45 | facet = NULL,
46 | facet2 = NULL,
47 | group = NULL,
48 | subgroup = NULL,
49 | label = NULL,
50 | text = NULL,
51 | sample = NULL,
52 | mapping = NULL,
53 | x_breaks = NULL,
54 | x_breaks_n = NULL,
55 | x_expand = NULL,
56 | x_limits_include = NULL,
57 | x_label = NULL,
58 | x_labels = NULL,
59 | x_position = "bottom",
60 | x_sec_axis = ggplot2::waiver(),
61 | x_symmetric = NULL,
62 | x_transform = NULL,
63 | y_breaks = NULL,
64 | y_breaks_n = NULL,
65 | y_expand = NULL,
66 | y_limits_include = NULL,
67 | y_label = NULL,
68 | y_labels = NULL,
69 | y_position = "left",
70 | y_sec_axis = ggplot2::waiver(),
71 | y_symmetric = NULL,
72 | y_transform = NULL,
73 | col_breaks = NULL,
74 | col_breaks_n = 5,
75 | col_drop = FALSE,
76 | col_limits_include = NULL,
77 | col_label = NULL,
78 | col_labels = NULL,
79 | col_legend_ncol = NULL,
80 | col_legend_nrow = NULL,
81 | col_legend_rev = FALSE,
82 | col_palette = NULL,
83 | col_palette_na = NULL,
84 | col_rescale = scales::rescale(),
85 | col_steps = FALSE,
86 | col_transform = NULL,
87 | facet_axes = NULL,
88 | facet_axis_labels = "margins",
89 | facet_drop = FALSE,
90 | facet_labels = NULL,
91 | facet_layout = NULL,
92 | facet_ncol = NULL,
93 | facet_nrow = NULL,
94 | facet_scales = "fixed",
95 | facet_space = "fixed",
96 | title = NULL,
97 | subtitle = NULL,
98 | caption = NULL,
99 | label_case = NULL
100 | ) {
101 | gg_blanket(
102 | data = data,
103 | geom = "sf",
104 | stat = stat,
105 | position = position,
106 | coord = coord,
107 | theme = theme,
108 | theme_orientation = theme_orientation,
109 | theme_axis_line_rm = theme_axis_line_rm,
110 | theme_axis_ticks_rm = theme_axis_ticks_rm,
111 | theme_panel_grid_rm = theme_panel_grid_rm,
112 | blend = blend,
113 | x = {{ x }},
114 | y = {{ y }},
115 | xmin = {{ xmin }},
116 | xmax = {{ xmax }},
117 | xend = {{ xend }},
118 | ymin = {{ ymin }},
119 | ymax = {{ ymax }},
120 | yend = {{ yend }},
121 | z = {{ z }},
122 | col = {{ col }},
123 | facet = {{ facet }},
124 | facet2 = {{ facet2 }},
125 | group = {{ group }},
126 | subgroup = {{ subgroup }},
127 | label = {{ label }},
128 | text = {{ text }},
129 | sample = {{ sample }},
130 | mapping = mapping,
131 | x_breaks = x_breaks,
132 | x_expand = x_expand,
133 | x_limits_include = x_limits_include,
134 | x_labels = x_labels,
135 | x_breaks_n = x_breaks_n,
136 | x_sec_axis = x_sec_axis,
137 | x_symmetric = x_symmetric,
138 | x_position = x_position,
139 | x_label = x_label,
140 | x_transform = x_transform,
141 | y_breaks = y_breaks,
142 | y_expand = y_expand,
143 | y_limits_include = y_limits_include,
144 | y_labels = y_labels,
145 | y_breaks_n = y_breaks_n,
146 | y_sec_axis = y_sec_axis,
147 | y_symmetric = y_symmetric,
148 | y_position = y_position,
149 | y_label = y_label,
150 | y_transform = y_transform,
151 | col_breaks = col_breaks,
152 | col_drop = col_drop,
153 | col_limits_include = col_limits_include,
154 | col_labels = col_labels,
155 | col_legend_ncol = col_legend_ncol,
156 | col_legend_nrow = col_legend_nrow,
157 | col_legend_rev = col_legend_rev,
158 | col_breaks_n = col_breaks_n,
159 | col_palette = col_palette,
160 | col_palette_na = col_palette_na,
161 | col_rescale = col_rescale,
162 | col_steps = col_steps,
163 | col_label = col_label,
164 | col_transform = col_transform,
165 | facet_axes = facet_axes,
166 | facet_axis_labels = facet_axis_labels,
167 | facet_drop = facet_drop,
168 | facet_labels = facet_labels,
169 | facet_layout = facet_layout,
170 | facet_ncol = facet_ncol,
171 | facet_nrow = facet_nrow,
172 | facet_scales = facet_scales,
173 | facet_space = facet_space,
174 | title = title,
175 | subtitle = subtitle,
176 | caption = caption,
177 | label_case = label_case,
178 | ...
179 | )
180 | }
181 |
--------------------------------------------------------------------------------
/R/gg_line.R:
--------------------------------------------------------------------------------
1 | #' Line ggplot
2 | #'
3 | #' @description Create a line ggplot with a wrapper around [ggplot2::ggplot()] + [geom_line()][ggplot2::geom_line()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' economics |>
17 | #' gg_line(
18 | #' x = date,
19 | #' y = unemploy,
20 | #' y_limits_include = 0,
21 | #' y_label = "Unemployment",
22 | #' )
23 | #'
24 | gg_line <- function(
25 | data = NULL,
26 | ...,
27 | stat = "identity",
28 | position = "identity",
29 | coord = ggplot2::coord_cartesian(clip = "off"),
30 | theme = NULL,
31 | theme_orientation = NULL,
32 | theme_axis_line_rm = NULL,
33 | theme_axis_ticks_rm = NULL,
34 | theme_panel_grid_rm = NULL,
35 | blend = NULL,
36 | x = NULL,
37 | xmin = NULL,
38 | xmax = NULL,
39 | xend = NULL,
40 | y = NULL,
41 | ymin = NULL,
42 | ymax = NULL,
43 | yend = NULL,
44 | z = NULL,
45 | col = NULL,
46 | facet = NULL,
47 | facet2 = NULL,
48 | group = NULL,
49 | subgroup = NULL,
50 | label = NULL,
51 | text = NULL,
52 | sample = NULL,
53 | mapping = NULL,
54 | x_breaks = NULL,
55 | x_breaks_n = NULL,
56 | x_expand = NULL,
57 | x_limits_include = NULL,
58 | x_label = NULL,
59 | x_labels = NULL,
60 | x_position = "bottom",
61 | x_sec_axis = ggplot2::waiver(),
62 | x_symmetric = NULL,
63 | x_transform = NULL,
64 | y_breaks = NULL,
65 | y_breaks_n = NULL,
66 | y_expand = NULL,
67 | y_limits_include = NULL,
68 | y_label = NULL,
69 | y_labels = NULL,
70 | y_position = "left",
71 | y_sec_axis = ggplot2::waiver(),
72 | y_symmetric = NULL,
73 | y_transform = NULL,
74 | col_breaks = NULL,
75 | col_breaks_n = 5,
76 | col_drop = FALSE,
77 | col_limits_include = NULL,
78 | col_label = NULL,
79 | col_labels = NULL,
80 | col_legend_ncol = NULL,
81 | col_legend_nrow = NULL,
82 | col_legend_rev = FALSE,
83 | col_palette = NULL,
84 | col_palette_na = NULL,
85 | col_rescale = scales::rescale(),
86 | col_steps = FALSE,
87 | col_transform = NULL,
88 | facet_axes = NULL,
89 | facet_axis_labels = "margins",
90 | facet_drop = FALSE,
91 | facet_labels = NULL,
92 | facet_layout = NULL,
93 | facet_ncol = NULL,
94 | facet_nrow = NULL,
95 | facet_scales = "fixed",
96 | facet_space = "fixed",
97 | title = NULL,
98 | subtitle = NULL,
99 | caption = NULL,
100 | label_case = NULL
101 | ) {
102 | gg_blanket(
103 | data = data,
104 | geom = "line",
105 | stat = stat,
106 | position = position,
107 | coord = coord,
108 | theme = theme,
109 | theme_orientation = theme_orientation,
110 | theme_axis_line_rm = theme_axis_line_rm,
111 | theme_axis_ticks_rm = theme_axis_ticks_rm,
112 | theme_panel_grid_rm = theme_panel_grid_rm,
113 | blend = blend,
114 | x = {{ x }},
115 | y = {{ y }},
116 | xmin = {{ xmin }},
117 | xmax = {{ xmax }},
118 | xend = {{ xend }},
119 | ymin = {{ ymin }},
120 | ymax = {{ ymax }},
121 | yend = {{ yend }},
122 | z = {{ z }},
123 | col = {{ col }},
124 | facet = {{ facet }},
125 | facet2 = {{ facet2 }},
126 | group = {{ group }},
127 | subgroup = {{ subgroup }},
128 | label = {{ label }},
129 | text = {{ text }},
130 | sample = {{ sample }},
131 | mapping = mapping,
132 | x_breaks = x_breaks,
133 | x_expand = x_expand,
134 | x_limits_include = x_limits_include,
135 | x_labels = x_labels,
136 | x_breaks_n = x_breaks_n,
137 | x_sec_axis = x_sec_axis,
138 | x_symmetric = x_symmetric,
139 | x_position = x_position,
140 | x_label = x_label,
141 | x_transform = x_transform,
142 | y_breaks = y_breaks,
143 | y_expand = y_expand,
144 | y_limits_include = y_limits_include,
145 | y_labels = y_labels,
146 | y_breaks_n = y_breaks_n,
147 | y_sec_axis = y_sec_axis,
148 | y_symmetric = y_symmetric,
149 | y_position = y_position,
150 | y_label = y_label,
151 | y_transform = y_transform,
152 | col_breaks = col_breaks,
153 | col_drop = col_drop,
154 | col_limits_include = col_limits_include,
155 | col_labels = col_labels,
156 | col_legend_ncol = col_legend_ncol,
157 | col_legend_nrow = col_legend_nrow,
158 | col_legend_rev = col_legend_rev,
159 | col_breaks_n = col_breaks_n,
160 | col_palette = col_palette,
161 | col_palette_na = col_palette_na,
162 | col_rescale = col_rescale,
163 | col_steps = col_steps,
164 | col_label = col_label,
165 | col_transform = col_transform,
166 | facet_axes = facet_axes,
167 | facet_axis_labels = facet_axis_labels,
168 | facet_drop = facet_drop,
169 | facet_labels = facet_labels,
170 | facet_layout = facet_layout,
171 | facet_ncol = facet_ncol,
172 | facet_nrow = facet_nrow,
173 | facet_scales = facet_scales,
174 | facet_space = facet_space,
175 | title = title,
176 | subtitle = subtitle,
177 | caption = caption,
178 | label_case = label_case,
179 | ...
180 | )
181 | }
182 |
--------------------------------------------------------------------------------
/R/gg_point.R:
--------------------------------------------------------------------------------
1 | #' Point ggplot
2 | #'
3 | #' @description Create a point ggplot with a wrapper around [ggplot2::ggplot()] + [geom_point()][ggplot2::geom_point()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_point(
19 | #' x = flipper_length_mm,
20 | #' y = body_mass_g,
21 | #' col = species,
22 | #' )
23 | #'
24 | gg_point <- function(
25 | data = NULL,
26 | ...,
27 | stat = "identity",
28 | position = "identity",
29 | coord = ggplot2::coord_cartesian(clip = "off"),
30 | theme = NULL,
31 | theme_orientation = NULL,
32 | theme_axis_line_rm = NULL,
33 | theme_axis_ticks_rm = NULL,
34 | theme_panel_grid_rm = NULL,
35 | blend = NULL,
36 | x = NULL,
37 | xmin = NULL,
38 | xmax = NULL,
39 | xend = NULL,
40 | y = NULL,
41 | ymin = NULL,
42 | ymax = NULL,
43 | yend = NULL,
44 | z = NULL,
45 | col = NULL,
46 | facet = NULL,
47 | facet2 = NULL,
48 | group = NULL,
49 | subgroup = NULL,
50 | label = NULL,
51 | text = NULL,
52 | sample = NULL,
53 | mapping = NULL,
54 | x_breaks = NULL,
55 | x_breaks_n = NULL,
56 | x_expand = NULL,
57 | x_limits_include = NULL,
58 | x_label = NULL,
59 | x_labels = NULL,
60 | x_position = "bottom",
61 | x_sec_axis = ggplot2::waiver(),
62 | x_symmetric = NULL,
63 | x_transform = NULL,
64 | y_breaks = NULL,
65 | y_breaks_n = NULL,
66 | y_expand = NULL,
67 | y_limits_include = NULL,
68 | y_label = NULL,
69 | y_labels = NULL,
70 | y_position = "left",
71 | y_sec_axis = ggplot2::waiver(),
72 | y_symmetric = NULL,
73 | y_transform = NULL,
74 | col_breaks = NULL,
75 | col_breaks_n = 5,
76 | col_drop = FALSE,
77 | col_limits_include = NULL,
78 | col_label = NULL,
79 | col_labels = NULL,
80 | col_legend_ncol = NULL,
81 | col_legend_nrow = NULL,
82 | col_legend_rev = FALSE,
83 | col_palette = NULL,
84 | col_palette_na = NULL,
85 | col_rescale = scales::rescale(),
86 | col_steps = FALSE,
87 | col_transform = NULL,
88 | facet_axes = NULL,
89 | facet_axis_labels = "margins",
90 | facet_drop = FALSE,
91 | facet_labels = NULL,
92 | facet_layout = NULL,
93 | facet_ncol = NULL,
94 | facet_nrow = NULL,
95 | facet_scales = "fixed",
96 | facet_space = "fixed",
97 | title = NULL,
98 | subtitle = NULL,
99 | caption = NULL,
100 | label_case = NULL
101 | ) {
102 | gg_blanket(
103 | data = data,
104 | geom = "point",
105 | stat = stat,
106 | position = position,
107 | coord = coord,
108 | theme = theme,
109 | theme_orientation = theme_orientation,
110 | theme_axis_line_rm = theme_axis_line_rm,
111 | theme_axis_ticks_rm = theme_axis_ticks_rm,
112 | theme_panel_grid_rm = theme_panel_grid_rm,
113 | blend = blend,
114 | x = {{ x }},
115 | y = {{ y }},
116 | xmin = {{ xmin }},
117 | xmax = {{ xmax }},
118 | xend = {{ xend }},
119 | ymin = {{ ymin }},
120 | ymax = {{ ymax }},
121 | yend = {{ yend }},
122 | z = {{ z }},
123 | col = {{ col }},
124 | facet = {{ facet }},
125 | facet2 = {{ facet2 }},
126 | group = {{ group }},
127 | subgroup = {{ subgroup }},
128 | label = {{ label }},
129 | text = {{ text }},
130 | sample = {{ sample }},
131 | mapping = mapping,
132 | x_breaks = x_breaks,
133 | x_expand = x_expand,
134 | x_limits_include = x_limits_include,
135 | x_labels = x_labels,
136 | x_breaks_n = x_breaks_n,
137 | x_sec_axis = x_sec_axis,
138 | x_symmetric = x_symmetric,
139 | x_position = x_position,
140 | x_label = x_label,
141 | x_transform = x_transform,
142 | y_breaks = y_breaks,
143 | y_expand = y_expand,
144 | y_limits_include = y_limits_include,
145 | y_labels = y_labels,
146 | y_breaks_n = y_breaks_n,
147 | y_sec_axis = y_sec_axis,
148 | y_symmetric = y_symmetric,
149 | y_position = y_position,
150 | y_label = y_label,
151 | y_transform = y_transform,
152 | col_breaks = col_breaks,
153 | col_drop = col_drop,
154 | col_limits_include = col_limits_include,
155 | col_labels = col_labels,
156 | col_legend_ncol = col_legend_ncol,
157 | col_legend_nrow = col_legend_nrow,
158 | col_legend_rev = col_legend_rev,
159 | col_breaks_n = col_breaks_n,
160 | col_palette = col_palette,
161 | col_palette_na = col_palette_na,
162 | col_rescale = col_rescale,
163 | col_steps = col_steps,
164 | col_label = col_label,
165 | col_transform = col_transform,
166 | facet_axes = facet_axes,
167 | facet_axis_labels = facet_axis_labels,
168 | facet_drop = facet_drop,
169 | facet_labels = facet_labels,
170 | facet_layout = facet_layout,
171 | facet_ncol = facet_ncol,
172 | facet_nrow = facet_nrow,
173 | facet_scales = facet_scales,
174 | facet_space = facet_space,
175 | title = title,
176 | subtitle = subtitle,
177 | caption = caption,
178 | label_case = label_case,
179 | ...
180 | )
181 | }
182 |
--------------------------------------------------------------------------------
/R/gg_histogram.R:
--------------------------------------------------------------------------------
1 | #' Histogram ggplot
2 | #'
3 | #' @description Create a histogram ggplot with a wrapper around [ggplot2::ggplot()] + [geom_histogram()][ggplot2::geom_histogram()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_histogram(
19 | #' x = flipper_length_mm,
20 | #' col = sex,
21 | #' bins = 50,
22 | #' )
23 | #'
24 | gg_histogram <- function(
25 | data = NULL,
26 | ...,
27 | stat = "bin",
28 | position = "stack",
29 | coord = ggplot2::coord_cartesian(clip = "off"),
30 | theme = NULL,
31 | theme_orientation = NULL,
32 | theme_axis_line_rm = NULL,
33 | theme_axis_ticks_rm = NULL,
34 | theme_panel_grid_rm = NULL,
35 | blend = NULL,
36 | x = NULL,
37 | xmin = NULL,
38 | xmax = NULL,
39 | xend = NULL,
40 | y = NULL,
41 | ymin = NULL,
42 | ymax = NULL,
43 | yend = NULL,
44 | z = NULL,
45 | col = NULL,
46 | facet = NULL,
47 | facet2 = NULL,
48 | group = NULL,
49 | subgroup = NULL,
50 | label = NULL,
51 | text = NULL,
52 | sample = NULL,
53 | mapping = NULL,
54 | x_breaks = NULL,
55 | x_breaks_n = NULL,
56 | x_expand = NULL,
57 | x_limits_include = NULL,
58 | x_label = NULL,
59 | x_labels = NULL,
60 | x_position = "bottom",
61 | x_sec_axis = ggplot2::waiver(),
62 | x_symmetric = NULL,
63 | x_transform = NULL,
64 | y_breaks = NULL,
65 | y_breaks_n = NULL,
66 | y_expand = NULL,
67 | y_limits_include = NULL,
68 | y_label = NULL,
69 | y_labels = NULL,
70 | y_position = "left",
71 | y_sec_axis = ggplot2::waiver(),
72 | y_symmetric = NULL,
73 | y_transform = NULL,
74 | col_breaks = NULL,
75 | col_breaks_n = 5,
76 | col_drop = FALSE,
77 | col_limits_include = NULL,
78 | col_label = NULL,
79 | col_labels = NULL,
80 | col_legend_ncol = NULL,
81 | col_legend_nrow = NULL,
82 | col_legend_rev = FALSE,
83 | col_palette = NULL,
84 | col_palette_na = NULL,
85 | col_rescale = scales::rescale(),
86 | col_steps = FALSE,
87 | col_transform = NULL,
88 | facet_axes = NULL,
89 | facet_axis_labels = "margins",
90 | facet_drop = FALSE,
91 | facet_labels = NULL,
92 | facet_layout = NULL,
93 | facet_ncol = NULL,
94 | facet_nrow = NULL,
95 | facet_scales = "fixed",
96 | facet_space = "fixed",
97 | title = NULL,
98 | subtitle = NULL,
99 | caption = NULL,
100 | label_case = NULL
101 | ) {
102 | gg_blanket(
103 | data = data,
104 | geom = "bar",
105 | stat = stat,
106 | position = position,
107 | coord = coord,
108 | theme = theme,
109 | theme_orientation = theme_orientation,
110 | theme_axis_line_rm = theme_axis_line_rm,
111 | theme_axis_ticks_rm = theme_axis_ticks_rm,
112 | theme_panel_grid_rm = theme_panel_grid_rm,
113 | blend = blend,
114 | x = {{ x }},
115 | y = {{ y }},
116 | xmin = {{ xmin }},
117 | xmax = {{ xmax }},
118 | xend = {{ xend }},
119 | ymin = {{ ymin }},
120 | ymax = {{ ymax }},
121 | yend = {{ yend }},
122 | z = {{ z }},
123 | col = {{ col }},
124 | facet = {{ facet }},
125 | facet2 = {{ facet2 }},
126 | group = {{ group }},
127 | subgroup = {{ subgroup }},
128 | label = {{ label }},
129 | text = {{ text }},
130 | sample = {{ sample }},
131 | mapping = mapping,
132 | x_breaks = x_breaks,
133 | x_expand = x_expand,
134 | x_limits_include = x_limits_include,
135 | x_labels = x_labels,
136 | x_breaks_n = x_breaks_n,
137 | x_sec_axis = x_sec_axis,
138 | x_symmetric = x_symmetric,
139 | x_position = x_position,
140 | x_label = x_label,
141 | x_transform = x_transform,
142 | y_breaks = y_breaks,
143 | y_expand = y_expand,
144 | y_limits_include = y_limits_include,
145 | y_labels = y_labels,
146 | y_breaks_n = y_breaks_n,
147 | y_sec_axis = y_sec_axis,
148 | y_symmetric = y_symmetric,
149 | y_position = y_position,
150 | y_label = y_label,
151 | y_transform = y_transform,
152 | col_breaks = col_breaks,
153 | col_drop = col_drop,
154 | col_limits_include = col_limits_include,
155 | col_labels = col_labels,
156 | col_legend_ncol = col_legend_ncol,
157 | col_legend_nrow = col_legend_nrow,
158 | col_legend_rev = col_legend_rev,
159 | col_breaks_n = col_breaks_n,
160 | col_palette = col_palette,
161 | col_palette_na = col_palette_na,
162 | col_rescale = col_rescale,
163 | col_steps = col_steps,
164 | col_label = col_label,
165 | col_transform = col_transform,
166 | facet_axes = facet_axes,
167 | facet_axis_labels = facet_axis_labels,
168 | facet_drop = facet_drop,
169 | facet_labels = facet_labels,
170 | facet_layout = facet_layout,
171 | facet_ncol = facet_ncol,
172 | facet_nrow = facet_nrow,
173 | facet_scales = facet_scales,
174 | facet_space = facet_space,
175 | title = title,
176 | subtitle = subtitle,
177 | caption = caption,
178 | label_case = label_case,
179 | ...
180 | )
181 | }
182 |
--------------------------------------------------------------------------------
/R/gg_density.R:
--------------------------------------------------------------------------------
1 | #' Density ggplot
2 | #'
3 | #' @description Create a density ggplot with a wrapper around [ggplot2::ggplot()] + [geom_density()][ggplot2::geom_density()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_density(
19 | #' x = flipper_length_mm,
20 | #' col = species,
21 | #' blend = "multiply",
22 | #' )
23 | #'
24 | gg_density <- function(
25 | data = NULL,
26 | ...,
27 | stat = "density",
28 | position = "identity",
29 | coord = ggplot2::coord_cartesian(clip = "off"),
30 | theme = NULL,
31 | theme_orientation = NULL,
32 | theme_axis_line_rm = NULL,
33 | theme_axis_ticks_rm = NULL,
34 | theme_panel_grid_rm = NULL,
35 | blend = NULL,
36 | x = NULL,
37 | xmin = NULL,
38 | xmax = NULL,
39 | xend = NULL,
40 | y = NULL,
41 | ymin = NULL,
42 | ymax = NULL,
43 | yend = NULL,
44 | z = NULL,
45 | col = NULL,
46 | facet = NULL,
47 | facet2 = NULL,
48 | group = NULL,
49 | subgroup = NULL,
50 | label = NULL,
51 | text = NULL,
52 | sample = NULL,
53 | mapping = NULL,
54 | x_breaks = NULL,
55 | x_breaks_n = NULL,
56 | x_expand = NULL,
57 | x_limits_include = NULL,
58 | x_label = NULL,
59 | x_labels = NULL,
60 | x_position = "bottom",
61 | x_sec_axis = ggplot2::waiver(),
62 | x_symmetric = NULL,
63 | x_transform = NULL,
64 | y_breaks = NULL,
65 | y_breaks_n = NULL,
66 | y_expand = NULL,
67 | y_limits_include = NULL,
68 | y_label = NULL,
69 | y_labels = NULL,
70 | y_position = "left",
71 | y_sec_axis = ggplot2::waiver(),
72 | y_symmetric = NULL,
73 | y_transform = NULL,
74 | col_breaks = NULL,
75 | col_breaks_n = 5,
76 | col_drop = FALSE,
77 | col_limits_include = NULL,
78 | col_label = NULL,
79 | col_labels = NULL,
80 | col_legend_ncol = NULL,
81 | col_legend_nrow = NULL,
82 | col_legend_rev = FALSE,
83 | col_palette = NULL,
84 | col_palette_na = NULL,
85 | col_rescale = scales::rescale(),
86 | col_steps = FALSE,
87 | col_transform = NULL,
88 | facet_axes = NULL,
89 | facet_axis_labels = "margins",
90 | facet_drop = FALSE,
91 | facet_labels = NULL,
92 | facet_layout = NULL,
93 | facet_ncol = NULL,
94 | facet_nrow = NULL,
95 | facet_scales = "fixed",
96 | facet_space = "fixed",
97 | title = NULL,
98 | subtitle = NULL,
99 | caption = NULL,
100 | label_case = NULL
101 | ) {
102 | gg_blanket(
103 | data = data,
104 | geom = "density",
105 | stat = stat,
106 | position = position,
107 | coord = coord,
108 | theme = theme,
109 | theme_orientation = theme_orientation,
110 | theme_axis_line_rm = theme_axis_line_rm,
111 | theme_axis_ticks_rm = theme_axis_ticks_rm,
112 | theme_panel_grid_rm = theme_panel_grid_rm,
113 | blend = blend,
114 | x = {{ x }},
115 | y = {{ y }},
116 | xmin = {{ xmin }},
117 | xmax = {{ xmax }},
118 | xend = {{ xend }},
119 | ymin = {{ ymin }},
120 | ymax = {{ ymax }},
121 | yend = {{ yend }},
122 | z = {{ z }},
123 | col = {{ col }},
124 | facet = {{ facet }},
125 | facet2 = {{ facet2 }},
126 | group = {{ group }},
127 | subgroup = {{ subgroup }},
128 | label = {{ label }},
129 | text = {{ text }},
130 | sample = {{ sample }},
131 | mapping = mapping,
132 | x_breaks = x_breaks,
133 | x_expand = x_expand,
134 | x_limits_include = x_limits_include,
135 | x_labels = x_labels,
136 | x_breaks_n = x_breaks_n,
137 | x_sec_axis = x_sec_axis,
138 | x_symmetric = x_symmetric,
139 | x_position = x_position,
140 | x_label = x_label,
141 | x_transform = x_transform,
142 | y_breaks = y_breaks,
143 | y_expand = y_expand,
144 | y_limits_include = y_limits_include,
145 | y_labels = y_labels,
146 | y_breaks_n = y_breaks_n,
147 | y_sec_axis = y_sec_axis,
148 | y_symmetric = y_symmetric,
149 | y_position = y_position,
150 | y_label = y_label,
151 | y_transform = y_transform,
152 | col_breaks = col_breaks,
153 | col_drop = col_drop,
154 | col_limits_include = col_limits_include,
155 | col_labels = col_labels,
156 | col_legend_ncol = col_legend_ncol,
157 | col_legend_nrow = col_legend_nrow,
158 | col_legend_rev = col_legend_rev,
159 | col_breaks_n = col_breaks_n,
160 | col_palette = col_palette,
161 | col_palette_na = col_palette_na,
162 | col_rescale = col_rescale,
163 | col_steps = col_steps,
164 | col_label = col_label,
165 | col_transform = col_transform,
166 | facet_axes = facet_axes,
167 | facet_axis_labels = facet_axis_labels,
168 | facet_drop = facet_drop,
169 | facet_labels = facet_labels,
170 | facet_layout = facet_layout,
171 | facet_ncol = facet_ncol,
172 | facet_nrow = facet_nrow,
173 | facet_scales = facet_scales,
174 | facet_space = facet_space,
175 | title = title,
176 | subtitle = subtitle,
177 | caption = caption,
178 | label_case = label_case,
179 | ...
180 | )
181 | }
182 |
--------------------------------------------------------------------------------
/R/gg_qq.R:
--------------------------------------------------------------------------------
1 | #' Qq ggplot
2 | #'
3 | #' @description Create a qq ggplot with a wrapper around [ggplot2::ggplot()] + [geom_qq()][ggplot2::geom_qq()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_qq(
19 | #' sample = body_mass_g,
20 | #' facet = species,
21 | #' coord = coord_cartesian(clip = "on"),
22 | #' ) +
23 | #' geom_qq_line()
24 | #'
25 | gg_qq <- function(
26 | data = NULL,
27 | ...,
28 | stat = "qq",
29 | position = "identity",
30 | coord = ggplot2::coord_cartesian(clip = "off"),
31 | theme = NULL,
32 | theme_orientation = NULL,
33 | theme_axis_line_rm = NULL,
34 | theme_axis_ticks_rm = NULL,
35 | theme_panel_grid_rm = NULL,
36 | blend = NULL,
37 | x = NULL,
38 | xmin = NULL,
39 | xmax = NULL,
40 | xend = NULL,
41 | y = NULL,
42 | ymin = NULL,
43 | ymax = NULL,
44 | yend = NULL,
45 | z = NULL,
46 | col = NULL,
47 | facet = NULL,
48 | facet2 = NULL,
49 | group = NULL,
50 | subgroup = NULL,
51 | label = NULL,
52 | text = NULL,
53 | sample = NULL,
54 | mapping = NULL,
55 | x_breaks = NULL,
56 | x_breaks_n = NULL,
57 | x_expand = NULL,
58 | x_limits_include = NULL,
59 | x_label = NULL,
60 | x_labels = NULL,
61 | x_position = "bottom",
62 | x_sec_axis = ggplot2::waiver(),
63 | x_symmetric = NULL,
64 | x_transform = NULL,
65 | y_breaks = NULL,
66 | y_breaks_n = NULL,
67 | y_expand = NULL,
68 | y_limits_include = NULL,
69 | y_label = NULL,
70 | y_labels = NULL,
71 | y_position = "left",
72 | y_sec_axis = ggplot2::waiver(),
73 | y_symmetric = NULL,
74 | y_transform = NULL,
75 | col_breaks = NULL,
76 | col_breaks_n = 5,
77 | col_drop = FALSE,
78 | col_limits_include = NULL,
79 | col_label = NULL,
80 | col_labels = NULL,
81 | col_legend_ncol = NULL,
82 | col_legend_nrow = NULL,
83 | col_legend_rev = FALSE,
84 | col_palette = NULL,
85 | col_palette_na = NULL,
86 | col_rescale = scales::rescale(),
87 | col_steps = FALSE,
88 | col_transform = NULL,
89 | facet_axes = NULL,
90 | facet_axis_labels = "margins",
91 | facet_drop = FALSE,
92 | facet_labels = NULL,
93 | facet_layout = NULL,
94 | facet_ncol = NULL,
95 | facet_nrow = NULL,
96 | facet_scales = "fixed",
97 | facet_space = "fixed",
98 | title = NULL,
99 | subtitle = NULL,
100 | caption = NULL,
101 | label_case = NULL
102 | ) {
103 | gg_blanket(
104 | data = data,
105 | geom = "point",
106 | stat = stat,
107 | position = position,
108 | coord = coord,
109 | theme = theme,
110 | theme_orientation = theme_orientation,
111 | theme_axis_line_rm = theme_axis_line_rm,
112 | theme_axis_ticks_rm = theme_axis_ticks_rm,
113 | theme_panel_grid_rm = theme_panel_grid_rm,
114 | blend = blend,
115 | x = {{ x }},
116 | y = {{ y }},
117 | xmin = {{ xmin }},
118 | xmax = {{ xmax }},
119 | xend = {{ xend }},
120 | ymin = {{ ymin }},
121 | ymax = {{ ymax }},
122 | yend = {{ yend }},
123 | z = {{ z }},
124 | col = {{ col }},
125 | facet = {{ facet }},
126 | facet2 = {{ facet2 }},
127 | group = {{ group }},
128 | subgroup = {{ subgroup }},
129 | label = {{ label }},
130 | text = {{ text }},
131 | sample = {{ sample }},
132 | mapping = mapping,
133 | x_breaks = x_breaks,
134 | x_expand = x_expand,
135 | x_limits_include = x_limits_include,
136 | x_labels = x_labels,
137 | x_breaks_n = x_breaks_n,
138 | x_sec_axis = x_sec_axis,
139 | x_symmetric = x_symmetric,
140 | x_position = x_position,
141 | x_label = x_label,
142 | x_transform = x_transform,
143 | y_breaks = y_breaks,
144 | y_expand = y_expand,
145 | y_limits_include = y_limits_include,
146 | y_labels = y_labels,
147 | y_breaks_n = y_breaks_n,
148 | y_sec_axis = y_sec_axis,
149 | y_symmetric = y_symmetric,
150 | y_position = y_position,
151 | y_label = y_label,
152 | y_transform = y_transform,
153 | col_breaks = col_breaks,
154 | col_drop = col_drop,
155 | col_limits_include = col_limits_include,
156 | col_labels = col_labels,
157 | col_legend_ncol = col_legend_ncol,
158 | col_legend_nrow = col_legend_nrow,
159 | col_legend_rev = col_legend_rev,
160 | col_breaks_n = col_breaks_n,
161 | col_palette = col_palette,
162 | col_palette_na = col_palette_na,
163 | col_rescale = col_rescale,
164 | col_steps = col_steps,
165 | col_label = col_label,
166 | col_transform = col_transform,
167 | facet_axes = facet_axes,
168 | facet_axis_labels = facet_axis_labels,
169 | facet_drop = facet_drop,
170 | facet_labels = facet_labels,
171 | facet_layout = facet_layout,
172 | facet_ncol = facet_ncol,
173 | facet_nrow = facet_nrow,
174 | facet_scales = facet_scales,
175 | facet_space = facet_space,
176 | title = title,
177 | subtitle = subtitle,
178 | caption = caption,
179 | label_case = label_case,
180 | ...
181 | )
182 | }
183 |
--------------------------------------------------------------------------------
/R/gg_violin.R:
--------------------------------------------------------------------------------
1 | #' Violin ggplot
2 | #'
3 | #' @description Create a violin plot with a wrapper around [ggplot2::ggplot()] + [geom_violin()][ggplot2::geom_violin()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' tidyr::drop_na(sex) |>
19 | #' gg_violin(
20 | #' x = species,
21 | #' y = body_mass_g,
22 | #' col = sex,
23 | #' )
24 | #'
25 | gg_violin <- function(
26 | data = NULL,
27 | ...,
28 | stat = "ydensity",
29 | position = "dodge",
30 | coord = ggplot2::coord_cartesian(clip = "off"),
31 | theme = NULL,
32 | theme_orientation = NULL,
33 | theme_axis_line_rm = NULL,
34 | theme_axis_ticks_rm = NULL,
35 | theme_panel_grid_rm = NULL,
36 | blend = NULL,
37 | x = NULL,
38 | xmin = NULL,
39 | xmax = NULL,
40 | xend = NULL,
41 | y = NULL,
42 | ymin = NULL,
43 | ymax = NULL,
44 | yend = NULL,
45 | z = NULL,
46 | col = NULL,
47 | facet = NULL,
48 | facet2 = NULL,
49 | group = NULL,
50 | subgroup = NULL,
51 | label = NULL,
52 | text = NULL,
53 | sample = NULL,
54 | mapping = NULL,
55 | x_breaks = NULL,
56 | x_breaks_n = NULL,
57 | x_expand = NULL,
58 | x_limits_include = NULL,
59 | x_label = NULL,
60 | x_labels = NULL,
61 | x_position = "bottom",
62 | x_sec_axis = ggplot2::waiver(),
63 | x_symmetric = NULL,
64 | x_transform = NULL,
65 | y_breaks = NULL,
66 | y_breaks_n = NULL,
67 | y_expand = NULL,
68 | y_limits_include = NULL,
69 | y_label = NULL,
70 | y_labels = NULL,
71 | y_position = "left",
72 | y_sec_axis = ggplot2::waiver(),
73 | y_symmetric = NULL,
74 | y_transform = NULL,
75 | col_breaks = NULL,
76 | col_breaks_n = 5,
77 | col_drop = FALSE,
78 | col_limits_include = NULL,
79 | col_label = NULL,
80 | col_labels = NULL,
81 | col_legend_ncol = NULL,
82 | col_legend_nrow = NULL,
83 | col_legend_rev = FALSE,
84 | col_palette = NULL,
85 | col_palette_na = NULL,
86 | col_rescale = scales::rescale(),
87 | col_steps = FALSE,
88 | col_transform = NULL,
89 | facet_axes = NULL,
90 | facet_axis_labels = "margins",
91 | facet_drop = FALSE,
92 | facet_labels = NULL,
93 | facet_layout = NULL,
94 | facet_ncol = NULL,
95 | facet_nrow = NULL,
96 | facet_scales = "fixed",
97 | facet_space = "fixed",
98 | title = NULL,
99 | subtitle = NULL,
100 | caption = NULL,
101 | label_case = NULL
102 | ) {
103 | gg_blanket(
104 | data = data,
105 | geom = "violin",
106 | stat = stat,
107 | position = position,
108 | coord = coord,
109 | theme = theme,
110 | theme_orientation = theme_orientation,
111 | theme_axis_line_rm = theme_axis_line_rm,
112 | theme_axis_ticks_rm = theme_axis_ticks_rm,
113 | theme_panel_grid_rm = theme_panel_grid_rm,
114 | blend = blend,
115 | x = {{ x }},
116 | y = {{ y }},
117 | xmin = {{ xmin }},
118 | xmax = {{ xmax }},
119 | xend = {{ xend }},
120 | ymin = {{ ymin }},
121 | ymax = {{ ymax }},
122 | yend = {{ yend }},
123 | z = {{ z }},
124 | col = {{ col }},
125 | facet = {{ facet }},
126 | facet2 = {{ facet2 }},
127 | group = {{ group }},
128 | subgroup = {{ subgroup }},
129 | label = {{ label }},
130 | text = {{ text }},
131 | sample = {{ sample }},
132 | mapping = mapping,
133 | x_breaks = x_breaks,
134 | x_expand = x_expand,
135 | x_limits_include = x_limits_include,
136 | x_labels = x_labels,
137 | x_breaks_n = x_breaks_n,
138 | x_sec_axis = x_sec_axis,
139 | x_symmetric = x_symmetric,
140 | x_position = x_position,
141 | x_label = x_label,
142 | x_transform = x_transform,
143 | y_breaks = y_breaks,
144 | y_expand = y_expand,
145 | y_limits_include = y_limits_include,
146 | y_labels = y_labels,
147 | y_breaks_n = y_breaks_n,
148 | y_sec_axis = y_sec_axis,
149 | y_symmetric = y_symmetric,
150 | y_position = y_position,
151 | y_label = y_label,
152 | y_transform = y_transform,
153 | col_breaks = col_breaks,
154 | col_drop = col_drop,
155 | col_limits_include = col_limits_include,
156 | col_labels = col_labels,
157 | col_legend_ncol = col_legend_ncol,
158 | col_legend_nrow = col_legend_nrow,
159 | col_legend_rev = col_legend_rev,
160 | col_breaks_n = col_breaks_n,
161 | col_palette = col_palette,
162 | col_palette_na = col_palette_na,
163 | col_rescale = col_rescale,
164 | col_steps = col_steps,
165 | col_label = col_label,
166 | col_transform = col_transform,
167 | facet_axes = facet_axes,
168 | facet_axis_labels = facet_axis_labels,
169 | facet_drop = facet_drop,
170 | facet_labels = facet_labels,
171 | facet_layout = facet_layout,
172 | facet_ncol = facet_ncol,
173 | facet_nrow = facet_nrow,
174 | facet_scales = facet_scales,
175 | facet_space = facet_space,
176 | title = title,
177 | subtitle = subtitle,
178 | caption = caption,
179 | label_case = label_case,
180 | ...
181 | )
182 | }
183 |
--------------------------------------------------------------------------------
/R/gg_function.R:
--------------------------------------------------------------------------------
1 | #' Function ggplot
2 | #'
3 | #' @description Create a function ggplot with a wrapper around [ggplot2::ggplot()] + [geom_function()][ggplot2::geom_function()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' gg_function(
17 | #' fun = \(x) dnorm(x, mean = 0, sd = 5),
18 | #' x_limits_include = qnorm(p = c(0.005, 0.995), mean = 0, sd = 5),
19 | #' y_limits_include = 0,
20 | #' )
21 | #'
22 | gg_function <- function(
23 | data = NULL,
24 | ...,
25 | stat = "function",
26 | position = "identity",
27 | coord = ggplot2::coord_cartesian(clip = "off"),
28 | theme = NULL,
29 | theme_orientation = NULL,
30 | theme_axis_line_rm = NULL,
31 | theme_axis_ticks_rm = NULL,
32 | theme_panel_grid_rm = NULL,
33 | blend = NULL,
34 | x = NULL,
35 | xmin = NULL,
36 | xmax = NULL,
37 | xend = NULL,
38 | y = NULL,
39 | ymin = NULL,
40 | ymax = NULL,
41 | yend = NULL,
42 | z = NULL,
43 | col = NULL,
44 | facet = NULL,
45 | facet2 = NULL,
46 | group = NULL,
47 | subgroup = NULL,
48 | label = NULL,
49 | text = NULL,
50 | sample = NULL,
51 | mapping = NULL,
52 | x_breaks = NULL,
53 | x_breaks_n = NULL,
54 | x_expand = NULL,
55 | x_limits_include = NULL,
56 | x_label = NULL,
57 | x_labels = NULL,
58 | x_position = "bottom",
59 | x_sec_axis = ggplot2::waiver(),
60 | x_symmetric = NULL,
61 | x_transform = NULL,
62 | y_breaks = NULL,
63 | y_breaks_n = NULL,
64 | y_expand = NULL,
65 | y_limits_include = NULL,
66 | y_label = NULL,
67 | y_labels = NULL,
68 | y_position = "left",
69 | y_sec_axis = ggplot2::waiver(),
70 | y_symmetric = NULL,
71 | y_transform = NULL,
72 | col_breaks = NULL,
73 | col_breaks_n = 5,
74 | col_drop = FALSE,
75 | col_limits_include = NULL,
76 | col_label = NULL,
77 | col_labels = NULL,
78 | col_legend_ncol = NULL,
79 | col_legend_nrow = NULL,
80 | col_legend_rev = FALSE,
81 | col_palette = NULL,
82 | col_palette_na = NULL,
83 | col_rescale = scales::rescale(),
84 | col_steps = FALSE,
85 | col_transform = NULL,
86 | facet_axes = NULL,
87 | facet_axis_labels = "margins",
88 | facet_drop = FALSE,
89 | facet_labels = NULL,
90 | facet_layout = NULL,
91 | facet_ncol = NULL,
92 | facet_nrow = NULL,
93 | facet_scales = "fixed",
94 | facet_space = "fixed",
95 | title = NULL,
96 | subtitle = NULL,
97 | caption = NULL,
98 | label_case = NULL
99 | ) {
100 | gg_blanket(
101 | data = data,
102 | geom = "function",
103 | stat = stat,
104 | position = position,
105 | coord = coord,
106 | theme = theme,
107 | theme_orientation = theme_orientation,
108 | theme_axis_line_rm = theme_axis_line_rm,
109 | theme_axis_ticks_rm = theme_axis_ticks_rm,
110 | theme_panel_grid_rm = theme_panel_grid_rm,
111 | blend = blend,
112 | x = {{ x }},
113 | y = {{ y }},
114 | xmin = {{ xmin }},
115 | xmax = {{ xmax }},
116 | xend = {{ xend }},
117 | ymin = {{ ymin }},
118 | ymax = {{ ymax }},
119 | yend = {{ yend }},
120 | z = {{ z }},
121 | col = {{ col }},
122 | facet = {{ facet }},
123 | facet2 = {{ facet2 }},
124 | group = {{ group }},
125 | subgroup = {{ subgroup }},
126 | label = {{ label }},
127 | text = {{ text }},
128 | sample = {{ sample }},
129 | mapping = mapping,
130 | x_breaks = x_breaks,
131 | x_expand = x_expand,
132 | x_limits_include = x_limits_include,
133 | x_labels = x_labels,
134 | x_breaks_n = x_breaks_n,
135 | x_sec_axis = x_sec_axis,
136 | x_symmetric = x_symmetric,
137 | x_position = x_position,
138 | x_label = x_label,
139 | x_transform = x_transform,
140 | y_breaks = y_breaks,
141 | y_expand = y_expand,
142 | y_limits_include = y_limits_include,
143 | y_labels = y_labels,
144 | y_breaks_n = y_breaks_n,
145 | y_sec_axis = y_sec_axis,
146 | y_symmetric = y_symmetric,
147 | y_position = y_position,
148 | y_label = y_label,
149 | y_transform = y_transform,
150 | col_breaks = col_breaks,
151 | col_drop = col_drop,
152 | col_limits_include = col_limits_include,
153 | col_labels = col_labels,
154 | col_legend_ncol = col_legend_ncol,
155 | col_legend_nrow = col_legend_nrow,
156 | col_legend_rev = col_legend_rev,
157 | col_breaks_n = col_breaks_n,
158 | col_palette = col_palette,
159 | col_palette_na = col_palette_na,
160 | col_rescale = col_rescale,
161 | col_steps = col_steps,
162 | col_label = col_label,
163 | col_transform = col_transform,
164 | facet_axes = facet_axes,
165 | facet_axis_labels = facet_axis_labels,
166 | facet_drop = facet_drop,
167 | facet_labels = facet_labels,
168 | facet_layout = facet_layout,
169 | facet_ncol = facet_ncol,
170 | facet_nrow = facet_nrow,
171 | facet_scales = facet_scales,
172 | facet_space = facet_space,
173 | title = title,
174 | subtitle = subtitle,
175 | caption = caption,
176 | label_case = label_case,
177 | ...
178 | )
179 | }
180 |
--------------------------------------------------------------------------------
/R/gg_boxplot.R:
--------------------------------------------------------------------------------
1 | #' Boxplot ggplot
2 | #'
3 | #' @description Create a boxplot ggplot with a wrapper around [ggplot2::ggplot()] + [geom_boxplot()][ggplot2::geom_boxplot()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_boxplot(
19 | #' x = flipper_length_mm,
20 | #' y = species,
21 | #' col = sex,
22 | #' blend = "multiply",
23 | #' )
24 | #'
25 | gg_boxplot <- function(
26 | data = NULL,
27 | ...,
28 | stat = "boxplot",
29 | position = "dodge2",
30 | coord = ggplot2::coord_cartesian(clip = "off"),
31 | theme = NULL,
32 | theme_orientation = NULL,
33 | theme_axis_line_rm = NULL,
34 | theme_axis_ticks_rm = NULL,
35 | theme_panel_grid_rm = NULL,
36 | blend = NULL,
37 | x = NULL,
38 | xmin = NULL,
39 | xmax = NULL,
40 | xend = NULL,
41 | y = NULL,
42 | ymin = NULL,
43 | ymax = NULL,
44 | yend = NULL,
45 | z = NULL,
46 | col = NULL,
47 | facet = NULL,
48 | facet2 = NULL,
49 | group = NULL,
50 | subgroup = NULL,
51 | label = NULL,
52 | text = NULL,
53 | sample = NULL,
54 | mapping = NULL,
55 | x_breaks = NULL,
56 | x_breaks_n = NULL,
57 | x_expand = NULL,
58 | x_limits_include = NULL,
59 | x_label = NULL,
60 | x_labels = NULL,
61 | x_position = "bottom",
62 | x_sec_axis = ggplot2::waiver(),
63 | x_symmetric = NULL,
64 | x_transform = NULL,
65 | y_breaks = NULL,
66 | y_breaks_n = NULL,
67 | y_expand = NULL,
68 | y_limits_include = NULL,
69 | y_label = NULL,
70 | y_labels = NULL,
71 | y_position = "left",
72 | y_sec_axis = ggplot2::waiver(),
73 | y_symmetric = NULL,
74 | y_transform = NULL,
75 | col_breaks = NULL,
76 | col_breaks_n = 5,
77 | col_drop = FALSE,
78 | col_limits_include = NULL,
79 | col_label = NULL,
80 | col_labels = NULL,
81 | col_legend_ncol = NULL,
82 | col_legend_nrow = NULL,
83 | col_legend_rev = FALSE,
84 | col_palette = NULL,
85 | col_palette_na = NULL,
86 | col_rescale = scales::rescale(),
87 | col_steps = FALSE,
88 | col_transform = NULL,
89 | facet_axes = NULL,
90 | facet_axis_labels = "margins",
91 | facet_drop = FALSE,
92 | facet_labels = NULL,
93 | facet_layout = NULL,
94 | facet_ncol = NULL,
95 | facet_nrow = NULL,
96 | facet_scales = "fixed",
97 | facet_space = "fixed",
98 | title = NULL,
99 | subtitle = NULL,
100 | caption = NULL,
101 | label_case = NULL
102 | ) {
103 | gg_blanket(
104 | data = data,
105 | geom = "boxplot",
106 | stat = stat,
107 | position = position,
108 | coord = coord,
109 | theme = theme,
110 | theme_orientation = theme_orientation,
111 | theme_axis_line_rm = theme_axis_line_rm,
112 | theme_axis_ticks_rm = theme_axis_ticks_rm,
113 | theme_panel_grid_rm = theme_panel_grid_rm,
114 | blend = blend,
115 | x = {{ x }},
116 | y = {{ y }},
117 | xmin = {{ xmin }},
118 | xmax = {{ xmax }},
119 | xend = {{ xend }},
120 | ymin = {{ ymin }},
121 | ymax = {{ ymax }},
122 | yend = {{ yend }},
123 | z = {{ z }},
124 | col = {{ col }},
125 | facet = {{ facet }},
126 | facet2 = {{ facet2 }},
127 | group = {{ group }},
128 | subgroup = {{ subgroup }},
129 | label = {{ label }},
130 | text = {{ text }},
131 | sample = {{ sample }},
132 | mapping = mapping,
133 | x_breaks = x_breaks,
134 | x_expand = x_expand,
135 | x_limits_include = x_limits_include,
136 | x_labels = x_labels,
137 | x_breaks_n = x_breaks_n,
138 | x_sec_axis = x_sec_axis,
139 | x_symmetric = x_symmetric,
140 | x_position = x_position,
141 | x_label = x_label,
142 | x_transform = x_transform,
143 | y_breaks = y_breaks,
144 | y_expand = y_expand,
145 | y_limits_include = y_limits_include,
146 | y_labels = y_labels,
147 | y_breaks_n = y_breaks_n,
148 | y_sec_axis = y_sec_axis,
149 | y_symmetric = y_symmetric,
150 | y_position = y_position,
151 | y_label = y_label,
152 | y_transform = y_transform,
153 | col_breaks = col_breaks,
154 | col_drop = col_drop,
155 | col_limits_include = col_limits_include,
156 | col_labels = col_labels,
157 | col_legend_ncol = col_legend_ncol,
158 | col_legend_nrow = col_legend_nrow,
159 | col_legend_rev = col_legend_rev,
160 | col_breaks_n = col_breaks_n,
161 | col_palette = col_palette,
162 | col_palette_na = col_palette_na,
163 | col_rescale = col_rescale,
164 | col_steps = col_steps,
165 | col_label = col_label,
166 | col_transform = col_transform,
167 | facet_axes = facet_axes,
168 | facet_axis_labels = facet_axis_labels,
169 | facet_drop = facet_drop,
170 | facet_labels = facet_labels,
171 | facet_layout = facet_layout,
172 | facet_ncol = facet_ncol,
173 | facet_nrow = facet_nrow,
174 | facet_scales = facet_scales,
175 | facet_space = facet_space,
176 | title = title,
177 | subtitle = subtitle,
178 | caption = caption,
179 | label_case = label_case,
180 | ...
181 | )
182 | }
183 |
--------------------------------------------------------------------------------
/R/gg_step.R:
--------------------------------------------------------------------------------
1 | #' Step ggplot
2 | #'
3 | #' @description Create a step plot with a wrapper around [ggplot2::ggplot()] + [geom_step()][ggplot2::geom_step()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' economics |>
17 | #' filter(date > lubridate::ymd("2010-01-01")) |>
18 | #' gg_step(
19 | #' x = date,
20 | #' y = unemploy,
21 | #' y_limits_include = 0,
22 | #' y_label = "Unemployment",
23 | #' )
24 | #'
25 | gg_step <- function(
26 | data = NULL,
27 | ...,
28 | stat = "identity",
29 | position = "identity",
30 | coord = ggplot2::coord_cartesian(clip = "off"),
31 | theme = NULL,
32 | theme_orientation = NULL,
33 | theme_axis_line_rm = NULL,
34 | theme_axis_ticks_rm = NULL,
35 | theme_panel_grid_rm = NULL,
36 | blend = NULL,
37 | x = NULL,
38 | xmin = NULL,
39 | xmax = NULL,
40 | xend = NULL,
41 | y = NULL,
42 | ymin = NULL,
43 | ymax = NULL,
44 | yend = NULL,
45 | z = NULL,
46 | col = NULL,
47 | facet = NULL,
48 | facet2 = NULL,
49 | group = NULL,
50 | subgroup = NULL,
51 | label = NULL,
52 | text = NULL,
53 | sample = NULL,
54 | mapping = NULL,
55 | x_breaks = NULL,
56 | x_breaks_n = NULL,
57 | x_expand = NULL,
58 | x_limits_include = NULL,
59 | x_label = NULL,
60 | x_labels = NULL,
61 | x_position = "bottom",
62 | x_sec_axis = ggplot2::waiver(),
63 | x_symmetric = NULL,
64 | x_transform = NULL,
65 | y_breaks = NULL,
66 | y_breaks_n = NULL,
67 | y_expand = NULL,
68 | y_limits_include = NULL,
69 | y_label = NULL,
70 | y_labels = NULL,
71 | y_position = "left",
72 | y_sec_axis = ggplot2::waiver(),
73 | y_symmetric = NULL,
74 | y_transform = NULL,
75 | col_breaks = NULL,
76 | col_breaks_n = 5,
77 | col_drop = FALSE,
78 | col_limits_include = NULL,
79 | col_label = NULL,
80 | col_labels = NULL,
81 | col_legend_ncol = NULL,
82 | col_legend_nrow = NULL,
83 | col_legend_rev = FALSE,
84 | col_palette = NULL,
85 | col_palette_na = NULL,
86 | col_rescale = scales::rescale(),
87 | col_steps = FALSE,
88 | col_transform = NULL,
89 | facet_axes = NULL,
90 | facet_axis_labels = "margins",
91 | facet_drop = FALSE,
92 | facet_labels = NULL,
93 | facet_layout = NULL,
94 | facet_ncol = NULL,
95 | facet_nrow = NULL,
96 | facet_scales = "fixed",
97 | facet_space = "fixed",
98 | title = NULL,
99 | subtitle = NULL,
100 | caption = NULL,
101 | label_case = NULL
102 | ) {
103 | gg_blanket(
104 | data = data,
105 | geom = "step",
106 | stat = stat,
107 | position = position,
108 | coord = coord,
109 | theme = theme,
110 | theme_orientation = theme_orientation,
111 | theme_axis_line_rm = theme_axis_line_rm,
112 | theme_axis_ticks_rm = theme_axis_ticks_rm,
113 | theme_panel_grid_rm = theme_panel_grid_rm,
114 | blend = blend,
115 | x = {{ x }},
116 | y = {{ y }},
117 | xmin = {{ xmin }},
118 | xmax = {{ xmax }},
119 | xend = {{ xend }},
120 | ymin = {{ ymin }},
121 | ymax = {{ ymax }},
122 | yend = {{ yend }},
123 | z = {{ z }},
124 | col = {{ col }},
125 | facet = {{ facet }},
126 | facet2 = {{ facet2 }},
127 | group = {{ group }},
128 | subgroup = {{ subgroup }},
129 | label = {{ label }},
130 | text = {{ text }},
131 | sample = {{ sample }},
132 | mapping = mapping,
133 | x_breaks = x_breaks,
134 | x_expand = x_expand,
135 | x_limits_include = x_limits_include,
136 | x_labels = x_labels,
137 | x_breaks_n = x_breaks_n,
138 | x_sec_axis = x_sec_axis,
139 | x_symmetric = x_symmetric,
140 | x_position = x_position,
141 | x_label = x_label,
142 | x_transform = x_transform,
143 | y_breaks = y_breaks,
144 | y_expand = y_expand,
145 | y_limits_include = y_limits_include,
146 | y_labels = y_labels,
147 | y_breaks_n = y_breaks_n,
148 | y_sec_axis = y_sec_axis,
149 | y_symmetric = y_symmetric,
150 | y_position = y_position,
151 | y_label = y_label,
152 | y_transform = y_transform,
153 | col_breaks = col_breaks,
154 | col_drop = col_drop,
155 | col_limits_include = col_limits_include,
156 | col_labels = col_labels,
157 | col_legend_ncol = col_legend_ncol,
158 | col_legend_nrow = col_legend_nrow,
159 | col_legend_rev = col_legend_rev,
160 | col_breaks_n = col_breaks_n,
161 | col_palette = col_palette,
162 | col_palette_na = col_palette_na,
163 | col_rescale = col_rescale,
164 | col_steps = col_steps,
165 | col_label = col_label,
166 | col_transform = col_transform,
167 | facet_axes = facet_axes,
168 | facet_axis_labels = facet_axis_labels,
169 | facet_drop = facet_drop,
170 | facet_labels = facet_labels,
171 | facet_layout = facet_layout,
172 | facet_ncol = facet_ncol,
173 | facet_nrow = facet_nrow,
174 | facet_scales = facet_scales,
175 | facet_space = facet_space,
176 | title = title,
177 | subtitle = subtitle,
178 | caption = caption,
179 | label_case = label_case,
180 | ...
181 | )
182 | }
183 |
--------------------------------------------------------------------------------
/R/gg_contour_filled.R:
--------------------------------------------------------------------------------
1 | #' Contour_filled ggplot
2 | #'
3 | #' @description Create a contour_filled ggplot with a wrapper around [ggplot2::ggplot()] + [geom_contour_filled()][ggplot2::geom_contour_filled()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #'
14 | #' set_blanket()
15 | #'
16 | #' faithfuld |>
17 | #' gg_contour_filled(
18 | #' x = waiting,
19 | #' y = eruptions,
20 | #' z = density,
21 | #' bins = 8,
22 | #' )
23 | #'
24 | gg_contour_filled <- function(
25 | data = NULL,
26 | ...,
27 | stat = "contour_filled",
28 | position = "identity",
29 | coord = ggplot2::coord_cartesian(clip = "off"),
30 | theme = NULL,
31 | theme_orientation = NULL,
32 | theme_axis_line_rm = NULL,
33 | theme_axis_ticks_rm = NULL,
34 | theme_panel_grid_rm = NULL,
35 | blend = NULL,
36 | x = NULL,
37 | xmin = NULL,
38 | xmax = NULL,
39 | xend = NULL,
40 | y = NULL,
41 | ymin = NULL,
42 | ymax = NULL,
43 | yend = NULL,
44 | z = NULL,
45 | col = NULL,
46 | facet = NULL,
47 | facet2 = NULL,
48 | group = NULL,
49 | subgroup = NULL,
50 | label = NULL,
51 | text = NULL,
52 | sample = NULL,
53 | mapping = NULL,
54 | x_breaks = NULL,
55 | x_breaks_n = NULL,
56 | x_expand = NULL,
57 | x_limits_include = NULL,
58 | x_label = NULL,
59 | x_labels = NULL,
60 | x_position = "bottom",
61 | x_sec_axis = ggplot2::waiver(),
62 | x_symmetric = NULL,
63 | x_transform = NULL,
64 | y_breaks = NULL,
65 | y_breaks_n = NULL,
66 | y_expand = NULL,
67 | y_limits_include = NULL,
68 | y_label = NULL,
69 | y_labels = NULL,
70 | y_position = "left",
71 | y_sec_axis = ggplot2::waiver(),
72 | y_symmetric = NULL,
73 | y_transform = NULL,
74 | col_breaks = NULL,
75 | col_breaks_n = 5,
76 | col_drop = FALSE,
77 | col_limits_include = NULL,
78 | col_label = NULL,
79 | col_labels = NULL,
80 | col_legend_ncol = NULL,
81 | col_legend_nrow = NULL,
82 | col_legend_rev = FALSE,
83 | col_palette = NULL,
84 | col_palette_na = NULL,
85 | col_rescale = scales::rescale(),
86 | col_steps = FALSE,
87 | col_transform = NULL,
88 | facet_axes = NULL,
89 | facet_axis_labels = "margins",
90 | facet_drop = FALSE,
91 | facet_labels = NULL,
92 | facet_layout = NULL,
93 | facet_ncol = NULL,
94 | facet_nrow = NULL,
95 | facet_scales = "fixed",
96 | facet_space = "fixed",
97 | title = NULL,
98 | subtitle = NULL,
99 | caption = NULL,
100 | label_case = NULL
101 | ) {
102 | gg_blanket(
103 | data = data,
104 | geom = "contour_filled",
105 | stat = stat,
106 | position = position,
107 | coord = coord,
108 | theme = theme,
109 | theme_orientation = theme_orientation,
110 | theme_axis_line_rm = theme_axis_line_rm,
111 | theme_axis_ticks_rm = theme_axis_ticks_rm,
112 | theme_panel_grid_rm = theme_panel_grid_rm,
113 | blend = blend,
114 | x = {{ x }},
115 | y = {{ y }},
116 | xmin = {{ xmin }},
117 | xmax = {{ xmax }},
118 | xend = {{ xend }},
119 | ymin = {{ ymin }},
120 | ymax = {{ ymax }},
121 | yend = {{ yend }},
122 | z = {{ z }},
123 | col = {{ col }},
124 | facet = {{ facet }},
125 | facet2 = {{ facet2 }},
126 | group = {{ group }},
127 | subgroup = {{ subgroup }},
128 | label = {{ label }},
129 | text = {{ text }},
130 | sample = {{ sample }},
131 | mapping = mapping,
132 | x_breaks = x_breaks,
133 | x_expand = x_expand,
134 | x_limits_include = x_limits_include,
135 | x_labels = x_labels,
136 | x_breaks_n = x_breaks_n,
137 | x_sec_axis = x_sec_axis,
138 | x_symmetric = x_symmetric,
139 | x_position = x_position,
140 | x_label = x_label,
141 | x_transform = x_transform,
142 | y_breaks = y_breaks,
143 | y_expand = y_expand,
144 | y_limits_include = y_limits_include,
145 | y_labels = y_labels,
146 | y_breaks_n = y_breaks_n,
147 | y_sec_axis = y_sec_axis,
148 | y_symmetric = y_symmetric,
149 | y_position = y_position,
150 | y_label = y_label,
151 | y_transform = y_transform,
152 | col_breaks = col_breaks,
153 | col_drop = col_drop,
154 | col_limits_include = col_limits_include,
155 | col_labels = col_labels,
156 | col_legend_ncol = col_legend_ncol,
157 | col_legend_nrow = col_legend_nrow,
158 | col_legend_rev = col_legend_rev,
159 | col_breaks_n = col_breaks_n,
160 | col_palette = col_palette,
161 | col_palette_na = col_palette_na,
162 | col_rescale = col_rescale,
163 | col_steps = col_steps,
164 | col_label = col_label,
165 | col_transform = col_transform,
166 | facet_axes = facet_axes,
167 | facet_axis_labels = facet_axis_labels,
168 | facet_drop = facet_drop,
169 | facet_labels = facet_labels,
170 | facet_layout = facet_layout,
171 | facet_ncol = facet_ncol,
172 | facet_nrow = facet_nrow,
173 | facet_scales = facet_scales,
174 | facet_space = facet_space,
175 | title = title,
176 | subtitle = subtitle,
177 | caption = caption,
178 | label_case = label_case,
179 | ...
180 | )
181 | }
182 |
--------------------------------------------------------------------------------
/R/gg_density_2d.R:
--------------------------------------------------------------------------------
1 | #' Density_2d ggplot
2 | #'
3 | #' @description Create a density_2d ggplot with a wrapper around [ggplot2::ggplot()] + [geom_density_2d()][ggplot2::geom_density_2d()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' faithful |>
18 | #' gg_density_2d(
19 | #' x = waiting,
20 | #' y = eruptions,
21 | #' bins = 8,
22 | #' contour = TRUE,
23 | #' )
24 | #'
25 | gg_density_2d <- function(
26 | data = NULL,
27 | ...,
28 | stat = "density_2d",
29 | position = "identity",
30 | coord = ggplot2::coord_cartesian(clip = "off"),
31 | theme = NULL,
32 | theme_orientation = NULL,
33 | theme_axis_line_rm = NULL,
34 | theme_axis_ticks_rm = NULL,
35 | theme_panel_grid_rm = NULL,
36 | blend = NULL,
37 | x = NULL,
38 | xmin = NULL,
39 | xmax = NULL,
40 | xend = NULL,
41 | y = NULL,
42 | ymin = NULL,
43 | ymax = NULL,
44 | yend = NULL,
45 | z = NULL,
46 | col = NULL,
47 | facet = NULL,
48 | facet2 = NULL,
49 | group = NULL,
50 | subgroup = NULL,
51 | label = NULL,
52 | text = NULL,
53 | sample = NULL,
54 | mapping = NULL,
55 | x_breaks = NULL,
56 | x_breaks_n = NULL,
57 | x_expand = NULL,
58 | x_limits_include = NULL,
59 | x_label = NULL,
60 | x_labels = NULL,
61 | x_position = "bottom",
62 | x_sec_axis = ggplot2::waiver(),
63 | x_symmetric = NULL,
64 | x_transform = NULL,
65 | y_breaks = NULL,
66 | y_breaks_n = NULL,
67 | y_expand = NULL,
68 | y_limits_include = NULL,
69 | y_label = NULL,
70 | y_labels = NULL,
71 | y_position = "left",
72 | y_sec_axis = ggplot2::waiver(),
73 | y_symmetric = NULL,
74 | y_transform = NULL,
75 | col_breaks = NULL,
76 | col_breaks_n = 5,
77 | col_drop = FALSE,
78 | col_limits_include = NULL,
79 | col_label = NULL,
80 | col_labels = NULL,
81 | col_legend_ncol = NULL,
82 | col_legend_nrow = NULL,
83 | col_legend_rev = FALSE,
84 | col_palette = NULL,
85 | col_palette_na = NULL,
86 | col_rescale = scales::rescale(),
87 | col_steps = FALSE,
88 | col_transform = NULL,
89 | facet_axes = NULL,
90 | facet_axis_labels = "margins",
91 | facet_drop = FALSE,
92 | facet_labels = NULL,
93 | facet_layout = NULL,
94 | facet_ncol = NULL,
95 | facet_nrow = NULL,
96 | facet_scales = "fixed",
97 | facet_space = "fixed",
98 | title = NULL,
99 | subtitle = NULL,
100 | caption = NULL,
101 | label_case = NULL
102 | ) {
103 | gg_blanket(
104 | data = data,
105 | geom = "density_2d",
106 | stat = stat,
107 | position = position,
108 | coord = coord,
109 | theme = theme,
110 | theme_orientation = theme_orientation,
111 | theme_axis_line_rm = theme_axis_line_rm,
112 | theme_axis_ticks_rm = theme_axis_ticks_rm,
113 | theme_panel_grid_rm = theme_panel_grid_rm,
114 | blend = blend,
115 | x = {{ x }},
116 | y = {{ y }},
117 | xmin = {{ xmin }},
118 | xmax = {{ xmax }},
119 | xend = {{ xend }},
120 | ymin = {{ ymin }},
121 | ymax = {{ ymax }},
122 | yend = {{ yend }},
123 | z = {{ z }},
124 | col = {{ col }},
125 | facet = {{ facet }},
126 | facet2 = {{ facet2 }},
127 | group = {{ group }},
128 | subgroup = {{ subgroup }},
129 | label = {{ label }},
130 | text = {{ text }},
131 | sample = {{ sample }},
132 | mapping = mapping,
133 | x_breaks = x_breaks,
134 | x_expand = x_expand,
135 | x_limits_include = x_limits_include,
136 | x_labels = x_labels,
137 | x_breaks_n = x_breaks_n,
138 | x_sec_axis = x_sec_axis,
139 | x_symmetric = x_symmetric,
140 | x_position = x_position,
141 | x_label = x_label,
142 | x_transform = x_transform,
143 | y_breaks = y_breaks,
144 | y_expand = y_expand,
145 | y_limits_include = y_limits_include,
146 | y_labels = y_labels,
147 | y_breaks_n = y_breaks_n,
148 | y_sec_axis = y_sec_axis,
149 | y_symmetric = y_symmetric,
150 | y_position = y_position,
151 | y_label = y_label,
152 | y_transform = y_transform,
153 | col_breaks = col_breaks,
154 | col_drop = col_drop,
155 | col_limits_include = col_limits_include,
156 | col_labels = col_labels,
157 | col_legend_ncol = col_legend_ncol,
158 | col_legend_nrow = col_legend_nrow,
159 | col_legend_rev = col_legend_rev,
160 | col_breaks_n = col_breaks_n,
161 | col_palette = col_palette,
162 | col_palette_na = col_palette_na,
163 | col_rescale = col_rescale,
164 | col_steps = col_steps,
165 | col_label = col_label,
166 | col_transform = col_transform,
167 | facet_axes = facet_axes,
168 | facet_axis_labels = facet_axis_labels,
169 | facet_drop = facet_drop,
170 | facet_labels = facet_labels,
171 | facet_layout = facet_layout,
172 | facet_ncol = facet_ncol,
173 | facet_nrow = facet_nrow,
174 | facet_scales = facet_scales,
175 | facet_space = facet_space,
176 | title = title,
177 | subtitle = subtitle,
178 | caption = caption,
179 | label_case = label_case,
180 | ...
181 | )
182 | }
183 |
--------------------------------------------------------------------------------
/R/gg_quantile.R:
--------------------------------------------------------------------------------
1 | #' Quantile ggplot
2 | #'
3 | #' @description Create an quantile ggplot with a wrapper around [ggplot2::ggplot()] + [geom_quantile()][ggplot2::geom_quantile()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' if (requireNamespace("quantreg", quietly = TRUE)) {
12 | #' library(ggplot2)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' gg_quantile(
19 | #' x = flipper_length_mm,
20 | #' y = body_mass_g,
21 | #' )
22 | #' }
23 | #'
24 | gg_quantile <- function(
25 | data = NULL,
26 | ...,
27 | stat = "quantile",
28 | position = "identity",
29 | coord = ggplot2::coord_cartesian(clip = "off"),
30 | theme = NULL,
31 | theme_orientation = NULL,
32 | theme_axis_line_rm = NULL,
33 | theme_axis_ticks_rm = NULL,
34 | theme_panel_grid_rm = NULL,
35 | blend = NULL,
36 | x = NULL,
37 | xmin = NULL,
38 | xmax = NULL,
39 | xend = NULL,
40 | y = NULL,
41 | ymin = NULL,
42 | ymax = NULL,
43 | yend = NULL,
44 | z = NULL,
45 | col = NULL,
46 | facet = NULL,
47 | facet2 = NULL,
48 | group = NULL,
49 | subgroup = NULL,
50 | label = NULL,
51 | text = NULL,
52 | sample = NULL,
53 | mapping = NULL,
54 | x_breaks = NULL,
55 | x_breaks_n = NULL,
56 | x_expand = NULL,
57 | x_limits_include = NULL,
58 | x_label = NULL,
59 | x_labels = NULL,
60 | x_position = "bottom",
61 | x_sec_axis = ggplot2::waiver(),
62 | x_symmetric = NULL,
63 | x_transform = NULL,
64 | y_breaks = NULL,
65 | y_breaks_n = NULL,
66 | y_expand = NULL,
67 | y_limits_include = NULL,
68 | y_label = NULL,
69 | y_labels = NULL,
70 | y_position = "left",
71 | y_sec_axis = ggplot2::waiver(),
72 | y_symmetric = NULL,
73 | y_transform = NULL,
74 | col_breaks = NULL,
75 | col_breaks_n = 5,
76 | col_drop = FALSE,
77 | col_limits_include = NULL,
78 | col_label = NULL,
79 | col_labels = NULL,
80 | col_legend_ncol = NULL,
81 | col_legend_nrow = NULL,
82 | col_legend_rev = FALSE,
83 | col_palette = NULL,
84 | col_palette_na = NULL,
85 | col_rescale = scales::rescale(),
86 | col_steps = FALSE,
87 | col_transform = NULL,
88 | facet_axes = NULL,
89 | facet_axis_labels = "margins",
90 | facet_drop = FALSE,
91 | facet_labels = NULL,
92 | facet_layout = NULL,
93 | facet_ncol = NULL,
94 | facet_nrow = NULL,
95 | facet_scales = "fixed",
96 | facet_space = "fixed",
97 | title = NULL,
98 | subtitle = NULL,
99 | caption = NULL,
100 | label_case = NULL
101 | ) {
102 | gg_blanket(
103 | data = data,
104 | geom = "quantile",
105 | stat = stat,
106 | position = position,
107 | coord = coord,
108 | theme = theme,
109 | theme_orientation = theme_orientation,
110 | theme_axis_line_rm = theme_axis_line_rm,
111 | theme_axis_ticks_rm = theme_axis_ticks_rm,
112 | theme_panel_grid_rm = theme_panel_grid_rm,
113 | blend = blend,
114 | x = {{ x }},
115 | y = {{ y }},
116 | xmin = {{ xmin }},
117 | xmax = {{ xmax }},
118 | xend = {{ xend }},
119 | ymin = {{ ymin }},
120 | ymax = {{ ymax }},
121 | yend = {{ yend }},
122 | z = {{ z }},
123 | col = {{ col }},
124 | facet = {{ facet }},
125 | facet2 = {{ facet2 }},
126 | group = {{ group }},
127 | subgroup = {{ subgroup }},
128 | label = {{ label }},
129 | text = {{ text }},
130 | sample = {{ sample }},
131 | mapping = mapping,
132 | x_breaks = x_breaks,
133 | x_expand = x_expand,
134 | x_limits_include = x_limits_include,
135 | x_labels = x_labels,
136 | x_breaks_n = x_breaks_n,
137 | x_sec_axis = x_sec_axis,
138 | x_symmetric = x_symmetric,
139 | x_position = x_position,
140 | x_label = x_label,
141 | x_transform = x_transform,
142 | y_breaks = y_breaks,
143 | y_expand = y_expand,
144 | y_limits_include = y_limits_include,
145 | y_labels = y_labels,
146 | y_breaks_n = y_breaks_n,
147 | y_sec_axis = y_sec_axis,
148 | y_symmetric = y_symmetric,
149 | y_position = y_position,
150 | y_label = y_label,
151 | y_transform = y_transform,
152 | col_breaks = col_breaks,
153 | col_drop = col_drop,
154 | col_limits_include = col_limits_include,
155 | col_labels = col_labels,
156 | col_legend_ncol = col_legend_ncol,
157 | col_legend_nrow = col_legend_nrow,
158 | col_legend_rev = col_legend_rev,
159 | col_breaks_n = col_breaks_n,
160 | col_palette = col_palette,
161 | col_palette_na = col_palette_na,
162 | col_rescale = col_rescale,
163 | col_steps = col_steps,
164 | col_label = col_label,
165 | col_transform = col_transform,
166 | facet_axes = facet_axes,
167 | facet_axis_labels = facet_axis_labels,
168 | facet_drop = facet_drop,
169 | facet_labels = facet_labels,
170 | facet_layout = facet_layout,
171 | facet_ncol = facet_ncol,
172 | facet_nrow = facet_nrow,
173 | facet_scales = facet_scales,
174 | facet_space = facet_space,
175 | title = title,
176 | subtitle = subtitle,
177 | caption = caption,
178 | label_case = label_case,
179 | ...
180 | )
181 | }
182 |
--------------------------------------------------------------------------------
/R/gg_segment.R:
--------------------------------------------------------------------------------
1 | #' Segment ggplot
2 | #'
3 | #' @description Create a segment ggplot with a wrapper around [ggplot2::ggplot()] + [geom_segment()][ggplot2::geom_segment()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' data.frame(x1 = 2.62, x2 = 3.57, y1 = 21.0, y2 = 15.0) |>
18 | #' gg_segment(
19 | #' x = x1,
20 | #' xend = x2,
21 | #' y = y1,
22 | #' yend = y2,
23 | #' )
24 | #'
25 | gg_segment <- function(
26 | data = NULL,
27 | ...,
28 | stat = "identity",
29 | position = "identity",
30 | coord = ggplot2::coord_cartesian(clip = "off"),
31 | theme = NULL,
32 | theme_orientation = NULL,
33 | theme_axis_line_rm = NULL,
34 | theme_axis_ticks_rm = NULL,
35 | theme_panel_grid_rm = NULL,
36 | blend = NULL,
37 | x = NULL,
38 | xmin = NULL,
39 | xmax = NULL,
40 | xend = NULL,
41 | y = NULL,
42 | ymin = NULL,
43 | ymax = NULL,
44 | yend = NULL,
45 | z = NULL,
46 | col = NULL,
47 | facet = NULL,
48 | facet2 = NULL,
49 | group = NULL,
50 | subgroup = NULL,
51 | label = NULL,
52 | text = NULL,
53 | sample = NULL,
54 | mapping = NULL,
55 | x_breaks = NULL,
56 | x_breaks_n = NULL,
57 | x_expand = NULL,
58 | x_limits_include = NULL,
59 | x_label = NULL,
60 | x_labels = NULL,
61 | x_position = "bottom",
62 | x_sec_axis = ggplot2::waiver(),
63 | x_symmetric = NULL,
64 | x_transform = NULL,
65 | y_breaks = NULL,
66 | y_breaks_n = NULL,
67 | y_expand = NULL,
68 | y_limits_include = NULL,
69 | y_label = NULL,
70 | y_labels = NULL,
71 | y_position = "left",
72 | y_sec_axis = ggplot2::waiver(),
73 | y_symmetric = NULL,
74 | y_transform = NULL,
75 | col_breaks = NULL,
76 | col_breaks_n = 5,
77 | col_drop = FALSE,
78 | col_limits_include = NULL,
79 | col_label = NULL,
80 | col_labels = NULL,
81 | col_legend_ncol = NULL,
82 | col_legend_nrow = NULL,
83 | col_legend_rev = FALSE,
84 | col_palette = NULL,
85 | col_palette_na = NULL,
86 | col_rescale = scales::rescale(),
87 | col_steps = FALSE,
88 | col_transform = NULL,
89 | facet_axes = NULL,
90 | facet_axis_labels = "margins",
91 | facet_drop = FALSE,
92 | facet_labels = NULL,
93 | facet_layout = NULL,
94 | facet_ncol = NULL,
95 | facet_nrow = NULL,
96 | facet_scales = "fixed",
97 | facet_space = "fixed",
98 | title = NULL,
99 | subtitle = NULL,
100 | caption = NULL,
101 | label_case = NULL
102 | ) {
103 | gg_blanket(
104 | data = data,
105 | geom = "segment",
106 | stat = stat,
107 | position = position,
108 | coord = coord,
109 | theme = theme,
110 | theme_orientation = theme_orientation,
111 | theme_axis_line_rm = theme_axis_line_rm,
112 | theme_axis_ticks_rm = theme_axis_ticks_rm,
113 | theme_panel_grid_rm = theme_panel_grid_rm,
114 | blend = blend,
115 | x = {{ x }},
116 | y = {{ y }},
117 | xmin = {{ xmin }},
118 | xmax = {{ xmax }},
119 | xend = {{ xend }},
120 | ymin = {{ ymin }},
121 | ymax = {{ ymax }},
122 | yend = {{ yend }},
123 | z = {{ z }},
124 | col = {{ col }},
125 | facet = {{ facet }},
126 | facet2 = {{ facet2 }},
127 | group = {{ group }},
128 | subgroup = {{ subgroup }},
129 | label = {{ label }},
130 | text = {{ text }},
131 | sample = {{ sample }},
132 | mapping = mapping,
133 | x_breaks = x_breaks,
134 | x_expand = x_expand,
135 | x_limits_include = x_limits_include,
136 | x_labels = x_labels,
137 | x_breaks_n = x_breaks_n,
138 | x_sec_axis = x_sec_axis,
139 | x_symmetric = x_symmetric,
140 | x_position = x_position,
141 | x_label = x_label,
142 | x_transform = x_transform,
143 | y_breaks = y_breaks,
144 | y_expand = y_expand,
145 | y_limits_include = y_limits_include,
146 | y_labels = y_labels,
147 | y_breaks_n = y_breaks_n,
148 | y_sec_axis = y_sec_axis,
149 | y_symmetric = y_symmetric,
150 | y_position = y_position,
151 | y_label = y_label,
152 | y_transform = y_transform,
153 | col_breaks = col_breaks,
154 | col_drop = col_drop,
155 | col_limits_include = col_limits_include,
156 | col_labels = col_labels,
157 | col_legend_ncol = col_legend_ncol,
158 | col_legend_nrow = col_legend_nrow,
159 | col_legend_rev = col_legend_rev,
160 | col_breaks_n = col_breaks_n,
161 | col_palette = col_palette,
162 | col_palette_na = col_palette_na,
163 | col_rescale = col_rescale,
164 | col_steps = col_steps,
165 | col_label = col_label,
166 | col_transform = col_transform,
167 | facet_axes = facet_axes,
168 | facet_axis_labels = facet_axis_labels,
169 | facet_drop = facet_drop,
170 | facet_labels = facet_labels,
171 | facet_layout = facet_layout,
172 | facet_ncol = facet_ncol,
173 | facet_nrow = facet_nrow,
174 | facet_scales = facet_scales,
175 | facet_space = facet_space,
176 | title = title,
177 | subtitle = subtitle,
178 | caption = caption,
179 | label_case = label_case,
180 | ...
181 | )
182 | }
183 |
--------------------------------------------------------------------------------
/R/standardise_width.R:
--------------------------------------------------------------------------------
1 | #' Standardise width
2 | #'
3 | #' Calculate widths that are standardised.
4 | #'
5 | #' @param ... Provided to force user argument naming etc.
6 | #' @param from_width In the reference, width value. Required.
7 | #' @param from_n In the reference, number of x aesthetic groups. Required.
8 | #' @param from_dodge_n In the reference, number of fill aesthetic etc groups dodged. Defaults to 1.
9 | #' @param from_dodge_padding In the reference, amount of padding (in position_dodge2). Defaults to 0.
10 | #' @param from_orientation In the reference, orientation of the plot. Either "x" (default) or "y".
11 | #' @param from_panel_widths In the reference, unit vector of individual panel widths. If NULL, panels assumed equal.
12 | #' @param from_panel_heights In the reference, unit vector of individual panel heights. If NULL, panels assumed equal.
13 | #' @param to_n Number of x aesthetic groups.
14 | #' @param to_dodge_n Number of fill aesthetic etc groups dodged. If NULL, inherits from from_dodge_n.
15 | #' @param to_dodge_padding Amount of padding (in position_dodge2). If NULL, inherits from from_dodge_padding.
16 | #' @param to_orientation Orientation of the plot. Either "x" or "y". If NULL, inherits from from_orientation.
17 | #' @param to_panel_widths Unit vector of individual panel widths. If NULL, inherits from from_panel_widths.
18 | #' @param to_panel_heights Unit vector of individual panel heights. If NULL, inherits from from_panel_heights.
19 | #'
20 | #' @returns A numeric value
21 | #' @noRd
22 | standardise_width <- function(
23 | ...,
24 | from_width,
25 | from_n,
26 | from_dodge_n = 1,
27 | from_dodge_padding = 0,
28 | from_orientation = "x",
29 | from_panel_widths = NULL,
30 | from_panel_heights = NULL,
31 | to_n = from_n,
32 | to_dodge_n = from_dodge_n,
33 | to_dodge_padding = from_dodge_padding,
34 | to_orientation = from_orientation,
35 | to_panel_widths = from_panel_widths,
36 | to_panel_heights = from_panel_heights
37 | ) {
38 | # Check required arguments
39 | if (missing(from_width) | missing(from_n)) {
40 | rlang::abort("Both from_width and from_n must be specified")
41 | }
42 |
43 | # Check orientation compatibility
44 | if (to_orientation == "y" & is.null(from_panel_heights)) {
45 | rlang::abort(
46 | "Cannot use to_orientation = 'y' when from_panel_heights is NULL"
47 | )
48 | }
49 |
50 | # Check for mixed units in panel dimensions
51 | panel_dims <- list(
52 | from_panel_widths,
53 | from_panel_heights,
54 | to_panel_widths,
55 | to_panel_heights
56 | )
57 | panel_dims <- panel_dims[!purrr::map_lgl(panel_dims, is.null)] # Remove NULL values
58 |
59 | if (length(panel_dims) > 1) {
60 | # Extract units from each non-NULL panel dimension
61 | units_list <- purrr::map_chr(panel_dims, function(x) {
62 | if (inherits(x, "unit")) {
63 | as.character(attr(x, "unit"))
64 | } else {
65 | "numeric" # Plain numeric values
66 | }
67 | })
68 |
69 | # Check if all units are the same
70 | if (length(unique(units_list)) > 1) {
71 | rlang::abort(
72 | "All panel dimensions must use the same units. Mixed units detected."
73 | )
74 | }
75 | }
76 |
77 | # Base category scaling
78 | base_width <- (to_n / from_n) * from_width
79 |
80 | # Dodge scaling: maintain consistent individual bar width
81 | if (to_dodge_n > 1 | from_dodge_n > 1) {
82 | width <- base_width * (to_dodge_n / from_dodge_n)
83 | } else {
84 | width <- base_width
85 | }
86 |
87 | # dodge_padding adjustment for position_dodge2
88 | if (to_dodge_padding > 0 | from_dodge_padding > 0) {
89 | # Adjust for difference in dodge_padding - more dodge_padding requires wider total width
90 | dodge_padding_factor <- (1 + to_dodge_padding) / (1 + from_dodge_padding)
91 | width <- width * dodge_padding_factor
92 | }
93 |
94 | # Panel dimension adjustment for visual consistency
95 | if (
96 | !is.null(to_panel_widths) |
97 | !is.null(to_panel_heights) |
98 | !is.null(from_panel_widths) |
99 | !is.null(from_panel_heights)
100 | ) {
101 | # Get the relevant dimension for each orientation
102 | # For orientation "x" (vertical bars): width depends on panel width
103 | # For orientation "y" (horizontal bars): width depends on panel height
104 |
105 | current_relevant_dim <- if (to_orientation == "x") {
106 | if (!is.null(to_panel_widths)) as.numeric(to_panel_widths)[1] else 1
107 | } else {
108 | if (!is.null(to_panel_heights)) as.numeric(to_panel_heights)[1] else 1
109 | }
110 |
111 | reference_relevant_dim <- if (from_orientation == "x") {
112 | if (!is.null(from_panel_widths)) as.numeric(from_panel_widths)[1] else 1
113 | } else {
114 | if (!is.null(from_panel_heights)) as.numeric(from_panel_heights)[1] else 1
115 | }
116 |
117 | # Scale to maintain visual consistency
118 | scaling_factor <- reference_relevant_dim / current_relevant_dim
119 | width <- width * scaling_factor
120 | }
121 |
122 | # Safety check
123 | if (any(width >= 1)) {
124 | rlang::abort("width cannot be greater than or equal to 1")
125 | }
126 |
127 | return(width)
128 | }
129 |
--------------------------------------------------------------------------------
/R/gg_tile.R:
--------------------------------------------------------------------------------
1 | #' Tile ggplot
2 | #'
3 | #' @description Create a tile plot with a wrapper around [ggplot2::ggplot()] + [geom_tile()][ggplot2::geom_tile()].
4 | #'
5 | #' @inheritParams gg_blanket
6 | #'
7 | #' @return A ggplot object.
8 | #' @export
9 | #'
10 | #' @examples
11 | #' library(ggplot2)
12 | #' library(dplyr)
13 | #' library(palmerpenguins)
14 | #'
15 | #' set_blanket()
16 | #'
17 | #' penguins |>
18 | #' group_by(species, sex) |>
19 | #' summarise(across(flipper_length_mm, \(x) mean(x, na.rm = TRUE))) |>
20 | #' gg_tile(
21 | #' x = sex,
22 | #' y = species,
23 | #' col = flipper_length_mm,
24 | #' )
25 | #'
26 | gg_tile <- function(
27 | data = NULL,
28 | ...,
29 | stat = "identity",
30 | position = "identity",
31 | coord = ggplot2::coord_cartesian(clip = "off"),
32 | theme = NULL,
33 | theme_orientation = NULL,
34 | theme_axis_line_rm = NULL,
35 | theme_axis_ticks_rm = NULL,
36 | theme_panel_grid_rm = NULL,
37 | blend = NULL,
38 | x = NULL,
39 | xmin = NULL,
40 | xmax = NULL,
41 | xend = NULL,
42 | y = NULL,
43 | ymin = NULL,
44 | ymax = NULL,
45 | yend = NULL,
46 | z = NULL,
47 | col = NULL,
48 | facet = NULL,
49 | facet2 = NULL,
50 | group = NULL,
51 | subgroup = NULL,
52 | label = NULL,
53 | text = NULL,
54 | sample = NULL,
55 | mapping = NULL,
56 | x_breaks = NULL,
57 | x_breaks_n = NULL,
58 | x_expand = NULL,
59 | x_limits_include = NULL,
60 | x_label = NULL,
61 | x_labels = NULL,
62 | x_position = "bottom",
63 | x_sec_axis = ggplot2::waiver(),
64 | x_symmetric = NULL,
65 | x_transform = NULL,
66 | y_breaks = NULL,
67 | y_breaks_n = NULL,
68 | y_expand = NULL,
69 | y_limits_include = NULL,
70 | y_label = NULL,
71 | y_labels = NULL,
72 | y_position = "left",
73 | y_sec_axis = ggplot2::waiver(),
74 | y_symmetric = NULL,
75 | y_transform = NULL,
76 | col_breaks = NULL,
77 | col_breaks_n = 5,
78 | col_drop = FALSE,
79 | col_limits_include = NULL,
80 | col_label = NULL,
81 | col_labels = NULL,
82 | col_legend_ncol = NULL,
83 | col_legend_nrow = NULL,
84 | col_legend_rev = FALSE,
85 | col_palette = NULL,
86 | col_palette_na = NULL,
87 | col_rescale = scales::rescale(),
88 | col_steps = FALSE,
89 | col_transform = NULL,
90 | facet_axes = NULL,
91 | facet_axis_labels = "margins",
92 | facet_drop = FALSE,
93 | facet_labels = NULL,
94 | facet_layout = NULL,
95 | facet_ncol = NULL,
96 | facet_nrow = NULL,
97 | facet_scales = "fixed",
98 | facet_space = "fixed",
99 | title = NULL,
100 | subtitle = NULL,
101 | caption = NULL,
102 | label_case = NULL
103 | ) {
104 | gg_blanket(
105 | data = data,
106 | geom = "tile",
107 | stat = stat,
108 | position = position,
109 | coord = coord,
110 | theme = theme,
111 | theme_orientation = theme_orientation,
112 | theme_axis_line_rm = theme_axis_line_rm,
113 | theme_axis_ticks_rm = theme_axis_ticks_rm,
114 | theme_panel_grid_rm = theme_panel_grid_rm,
115 | blend = blend,
116 | x = {{ x }},
117 | y = {{ y }},
118 | xmin = {{ xmin }},
119 | xmax = {{ xmax }},
120 | xend = {{ xend }},
121 | ymin = {{ ymin }},
122 | ymax = {{ ymax }},
123 | yend = {{ yend }},
124 | z = {{ z }},
125 | col = {{ col }},
126 | facet = {{ facet }},
127 | facet2 = {{ facet2 }},
128 | group = {{ group }},
129 | subgroup = {{ subgroup }},
130 | label = {{ label }},
131 | text = {{ text }},
132 | sample = {{ sample }},
133 | mapping = mapping,
134 | x_breaks = x_breaks,
135 | x_expand = x_expand,
136 | x_limits_include = x_limits_include,
137 | x_labels = x_labels,
138 | x_breaks_n = x_breaks_n,
139 | x_sec_axis = x_sec_axis,
140 | x_symmetric = x_symmetric,
141 | x_position = x_position,
142 | x_label = x_label,
143 | x_transform = x_transform,
144 | y_breaks = y_breaks,
145 | y_expand = y_expand,
146 | y_limits_include = y_limits_include,
147 | y_labels = y_labels,
148 | y_breaks_n = y_breaks_n,
149 | y_sec_axis = y_sec_axis,
150 | y_symmetric = y_symmetric,
151 | y_position = y_position,
152 | y_label = y_label,
153 | y_transform = y_transform,
154 | col_breaks = col_breaks,
155 | col_drop = col_drop,
156 | col_limits_include = col_limits_include,
157 | col_labels = col_labels,
158 | col_legend_ncol = col_legend_ncol,
159 | col_legend_nrow = col_legend_nrow,
160 | col_legend_rev = col_legend_rev,
161 | col_breaks_n = col_breaks_n,
162 | col_palette = col_palette,
163 | col_palette_na = col_palette_na,
164 | col_rescale = col_rescale,
165 | col_steps = col_steps,
166 | col_label = col_label,
167 | col_transform = col_transform,
168 | facet_axes = facet_axes,
169 | facet_axis_labels = facet_axis_labels,
170 | facet_drop = facet_drop,
171 | facet_labels = facet_labels,
172 | facet_layout = facet_layout,
173 | facet_ncol = facet_ncol,
174 | facet_nrow = facet_nrow,
175 | facet_scales = facet_scales,
176 | facet_space = facet_space,
177 | title = title,
178 | subtitle = subtitle,
179 | caption = caption,
180 | label_case = label_case,
181 | ...
182 | )
183 | }
184 |
--------------------------------------------------------------------------------