diff --git a/NAMESPACE b/NAMESPACE index 9b52825..2e5a522 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -40,7 +40,7 @@ export(gizmo_density) export(gizmo_grob) export(gizmo_histogram) export(gizmo_stepcap) -export(guide_axis_custom) +export(guide_axis_base) export(guide_axis_nested) export(guide_colbar) export(guide_colring) diff --git a/NEWS.md b/NEWS.md index 0db2f75..5ea29c7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,9 +17,9 @@ are represented. Full guides are guides that you can just drop in the `guides()` function or as `guide` argument to scales. -* `guide_axis_custom()` as an axis guide. -* `guide_colbar_custom()` as a continuous colour/fill guide. -* `guide_colsteps_custom()` as a binned colour/fill guide. +* `guide_axis_base()` as an axis guide. +* `guide_colbar()` as a continuous colour/fill guide. +* `guide_colsteps()` as a binned colour/fill guide. * `guide_colring()` as a continuous colour/fill guide. * `guide_subtitle()` as a colour/fill guide. diff --git a/R/compose-ontop.R b/R/compose-ontop.R index 72bd872..ae3a801 100644 --- a/R/compose-ontop.R +++ b/R/compose-ontop.R @@ -16,14 +16,14 @@ #' ggplot(mpg, aes(displ, hwy)) + #' geom_point() + #' guides(x = compose_ontop( -#' guide_axis_custom( +#' guide_axis_base( #' key_manual(c(2, 4, 6)), #' theme = theme( #' axis.ticks = element_line(colour = "limegreen"), #' axis.ticks.length = unit(11, "pt") #' ) #' ), -#' guide_axis_custom( +#' guide_axis_base( #' key_manual(c(3, 5, 7)), #' theme = theme( #' axis.ticks = element_line(colour = "tomato"), diff --git a/R/compose-sandwich.R b/R/compose-sandwich.R index e20f228..1a0c3ac 100644 --- a/R/compose-sandwich.R +++ b/R/compose-sandwich.R @@ -30,7 +30,7 @@ #' geom_point(aes(colour = cty)) + #' guides(colour = compose_sandwich( #' middle = "colourbar", -#' text = "axis_custom", +#' text = "axis_base", #' opposite = primitive_bracket(key = key_range_manual( #' start = c(10, 20), end = c(25, 30), name = c("A", "B") #' )) diff --git a/R/guide_axis_custom.R b/R/guide_axis_base.R similarity index 92% rename from R/guide_axis_custom.R rename to R/guide_axis_base.R index e33fe90..7a33436 100644 --- a/R/guide_axis_custom.R +++ b/R/guide_axis_base.R @@ -35,10 +35,10 @@ #' p <- ggplot(mpg, aes(displ, hwy)) + #' geom_point() + #' scale_x_continuous( -#' guide = guide_axis_custom(key = key_minor()) +#' guide = guide_axis_base(key = key_minor()) #' ) + #' scale_y_continuous( -#' guide = guide_axis_custom(key = key_manual(c(20, 25, 30, 40))) +#' guide = guide_axis_base(key = key_manual(c(20, 25, 30, 40))) #' ) #' p #' @@ -50,9 +50,9 @@ #' geom_point(na.rm = TRUE) + #' scale_x_continuous( #' transform = "log10", -#' guide = guide_axis_custom("log") +#' guide = guide_axis_base("log") #' ) -guide_axis_custom <- function( +guide_axis_base <- function( key = NULL, title = waiver(), theme = NULL, n.dodge = 1, check.overlap = FALSE, angle = waiver(), cap = "none", bidi = FALSE, order = 0, position = waiver() diff --git a/R/guide_colbar.R b/R/guide_colbar.R index 5b89919..adbc7bf 100644 --- a/R/guide_colbar.R +++ b/R/guide_colbar.R @@ -78,7 +78,7 @@ guide_colbar <- function( title = waiver(), key = "auto", - first_guide = "axis_custom", + first_guide = "axis_base", second_guide = first_guide, shape = "triangle", size = NULL, diff --git a/R/guide_colring.R b/R/guide_colring.R index 93bf899..b1771f3 100644 --- a/R/guide_colring.R +++ b/R/guide_colring.R @@ -66,8 +66,8 @@ guide_colring <- function( key = "auto", start = 0, end = NULL, - outer_guide = "axis_custom", - inner_guide = "axis_custom", + outer_guide = "axis_base", + inner_guide = "axis_base", nbin = 300, reverse = FALSE, show_labels = "outer", diff --git a/R/guide_colsteps.R b/R/guide_colsteps.R index 0417f44..b34e9c9 100644 --- a/R/guide_colsteps.R +++ b/R/guide_colsteps.R @@ -70,15 +70,15 @@ #' # Using tick marks by swapping side guides #' p + scale_colour_viridis_b( #' guide = guide_colsteps( -#' first_guide = "axis_custom", -#' second_guide = "axis_custom" +#' first_guide = "axis_base", +#' second_guide = "axis_base" #' ) #' ) guide_colsteps <- function( title = waiver(), key = "bins", - first_guide = "axis_custom", - second_guide = "axis_custom", + first_guide = "axis_base", + second_guide = "axis_base", shape = "triangle", size = NULL, show = NA, diff --git a/README.Rmd b/README.Rmd index bae65e3..880f66e 100644 --- a/README.Rmd +++ b/README.Rmd @@ -56,7 +56,7 @@ base <- ggplot(mpg, aes(displ, hwy, colour = cty)) + The gguidance package offers a selection of what it calls 'complete guides'. These complete guides can just be drop-in replacement of regular guides, which you can specify using ggplot2's `guides()` function or using the `guide` argument in scales. -In the example below, we're using two custom variants of vanilla guides, namely `guide_axis_custom()` and `guide_colbar()`. These custom variants have additional options that allow a greater degree of customisation: +In the example below, we're using two custom variants of vanilla guides, namely `guide_axis_base()` and `guide_colbar()`. These custom variants have additional options that allow a greater degree of customisation: * The axis guide has an option for bidirectional ticks. * The colourbar automatically recognises out-of-bounds values and displays this with a cap. @@ -68,7 +68,7 @@ base + guide = "colbar" ) + guides( - x = guide_axis_custom(bidi = TRUE) + x = guide_axis_base(bidi = TRUE) ) ``` @@ -103,7 +103,7 @@ base + scale_colour_viridis_c( guide = compose_sandwich( middle = gizmo_density(), - text = "axis_custom", + text = "axis_base", opposite = efficient_bracket ) ) diff --git a/README.md b/README.md index ce89014..5ad6e3a 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ guides’. These complete guides can just be drop-in replacement of regular guides, which you can specify using ggplot2’s `guides()` function or using the `guide` argument in scales. In the example below, we’re using two custom variants of vanilla guides, namely -`guide_axis_custom()` and `guide_colbar()`. These custom variants have +`guide_axis_base()` and `guide_colbar()`. These custom variants have additional options that allow a greater degree of customisation: - The axis guide has an option for bidirectional ticks. @@ -63,7 +63,7 @@ base + guide = "colbar" ) + guides( - x = guide_axis_custom(bidi = TRUE) + x = guide_axis_base(bidi = TRUE) ) ``` @@ -106,7 +106,7 @@ base + scale_colour_viridis_c( guide = compose_sandwich( middle = gizmo_density(), - text = "axis_custom", + text = "axis_base", opposite = efficient_bracket ) ) diff --git a/man/compose_ontop.Rd b/man/compose_ontop.Rd index ff0ff38..4ffb762 100644 --- a/man/compose_ontop.Rd +++ b/man/compose_ontop.Rd @@ -76,14 +76,14 @@ This guide can place place other guides on top of one another. ggplot(mpg, aes(displ, hwy)) + geom_point() + guides(x = compose_ontop( - guide_axis_custom( + guide_axis_base( key_manual(c(2, 4, 6)), theme = theme( axis.ticks = element_line(colour = "limegreen"), axis.ticks.length = unit(11, "pt") ) ), - guide_axis_custom( + guide_axis_base( key_manual(c(3, 5, 7)), theme = theme( axis.ticks = element_line(colour = "tomato"), diff --git a/man/compose_sandwich.Rd b/man/compose_sandwich.Rd index b95cd86..ca88a2d 100644 --- a/man/compose_sandwich.Rd +++ b/man/compose_sandwich.Rd @@ -88,7 +88,7 @@ ggplot(mpg, aes(displ, hwy)) + geom_point(aes(colour = cty)) + guides(colour = compose_sandwich( middle = "colourbar", - text = "axis_custom", + text = "axis_base", opposite = primitive_bracket(key = key_range_manual( start = c(10, 20), end = c(25, 30), name = c("A", "B") )) diff --git a/man/guide_axis_custom.Rd b/man/guide_axis_base.Rd similarity index 94% rename from man/guide_axis_custom.Rd rename to man/guide_axis_base.Rd index 7acd2e5..bd28e30 100644 --- a/man/guide_axis_custom.Rd +++ b/man/guide_axis_base.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/guide_axis_custom.R -\name{guide_axis_custom} -\alias{guide_axis_custom} +% Please edit documentation in R/guide_axis_base.R +\name{guide_axis_base} +\alias{guide_axis_base} \title{Custom axis guide} \usage{ -guide_axis_custom( +guide_axis_base( key = NULL, title = waiver(), theme = NULL, @@ -103,10 +103,10 @@ To use this as a logarithmic axis, set \code{key = "log"}. p <- ggplot(mpg, aes(displ, hwy)) + geom_point() + scale_x_continuous( - guide = guide_axis_custom(key = key_minor()) + guide = guide_axis_base(key = key_minor()) ) + scale_y_continuous( - guide = guide_axis_custom(key = key_manual(c(20, 25, 30, 40))) + guide = guide_axis_base(key = key_manual(c(20, 25, 30, 40))) ) p @@ -118,7 +118,7 @@ ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_continuous( transform = "log10", - guide = guide_axis_custom("log") + guide = guide_axis_base("log") ) } \seealso{ diff --git a/man/guide_axis_nested.Rd b/man/guide_axis_nested.Rd index d8cb73c..d99761a 100644 --- a/man/guide_axis_nested.Rd +++ b/man/guide_axis_nested.Rd @@ -161,7 +161,7 @@ ggplot(mpg, aes(displ, hwy)) + } \seealso{ Other standalone guides: -\code{\link{guide_axis_custom}()}, +\code{\link{guide_axis_base}()}, \code{\link{guide_colbar}()}, \code{\link{guide_colring}()}, \code{\link{guide_colsteps}()} diff --git a/man/guide_colbar.Rd b/man/guide_colbar.Rd index 0fde24a..3b21908 100644 --- a/man/guide_colbar.Rd +++ b/man/guide_colbar.Rd @@ -7,7 +7,7 @@ guide_colbar( title = waiver(), key = "auto", - first_guide = "axis_custom", + first_guide = "axis_base", second_guide = first_guide, shape = "triangle", size = NULL, @@ -155,7 +155,7 @@ ggplot(msleep, aes(sleep_total, sleep_rem)) + } \seealso{ Other standalone guides: -\code{\link{guide_axis_custom}()}, +\code{\link{guide_axis_base}()}, \code{\link{guide_axis_nested}()}, \code{\link{guide_colring}()}, \code{\link{guide_colsteps}()} diff --git a/man/guide_colring.Rd b/man/guide_colring.Rd index fa9596c..c444ef9 100644 --- a/man/guide_colring.Rd +++ b/man/guide_colring.Rd @@ -9,8 +9,8 @@ guide_colring( key = "auto", start = 0, end = NULL, - outer_guide = "axis_custom", - inner_guide = "axis_custom", + outer_guide = "axis_base", + inner_guide = "axis_base", nbin = 300, reverse = FALSE, show_labels = "outer", @@ -107,7 +107,7 @@ p + guides(colour = guide_colring(angle = 0)) } \seealso{ Other standalone guides: -\code{\link{guide_axis_custom}()}, +\code{\link{guide_axis_base}()}, \code{\link{guide_axis_nested}()}, \code{\link{guide_colbar}()}, \code{\link{guide_colsteps}()} diff --git a/man/guide_colsteps.Rd b/man/guide_colsteps.Rd index 4c643b3..875bd21 100644 --- a/man/guide_colsteps.Rd +++ b/man/guide_colsteps.Rd @@ -7,8 +7,8 @@ guide_colsteps( title = waiver(), key = "bins", - first_guide = "axis_custom", - second_guide = "axis_custom", + first_guide = "axis_base", + second_guide = "axis_base", shape = "triangle", size = NULL, show = NA, @@ -145,14 +145,14 @@ p + scale_colour_viridis_b( # Using tick marks by swapping side guides p + scale_colour_viridis_b( guide = guide_colsteps( - first_guide = "axis_custom", - second_guide = "axis_custom" + first_guide = "axis_base", + second_guide = "axis_base" ) ) } \seealso{ Other standalone guides: -\code{\link{guide_axis_custom}()}, +\code{\link{guide_axis_base}()}, \code{\link{guide_axis_nested}()}, \code{\link{guide_colbar}()}, \code{\link{guide_colring}()} diff --git a/tests/testthat/_snaps/guide_axis_custom/guide-axis-custom-cartesian.svg b/tests/testthat/_snaps/guide_axis_custom/guide-axis-base-cartesian.svg similarity index 99% rename from tests/testthat/_snaps/guide_axis_custom/guide-axis-custom-cartesian.svg rename to tests/testthat/_snaps/guide_axis_custom/guide-axis-base-cartesian.svg index 7a9f073..5ee38b4 100644 --- a/tests/testthat/_snaps/guide_axis_custom/guide-axis-custom-cartesian.svg +++ b/tests/testthat/_snaps/guide_axis_custom/guide-axis-base-cartesian.svg @@ -142,6 +142,6 @@ 4 bodywt awake -guide_axis_custom cartesian +guide_axis_base cartesian diff --git a/tests/testthat/_snaps/guide_axis_custom/guide-axis-custom-radial.svg b/tests/testthat/_snaps/guide_axis_custom/guide-axis-base-radial.svg similarity index 99% rename from tests/testthat/_snaps/guide_axis_custom/guide-axis-custom-radial.svg rename to tests/testthat/_snaps/guide_axis_custom/guide-axis-base-radial.svg index 2525c66..0a1c942 100644 --- a/tests/testthat/_snaps/guide_axis_custom/guide-axis-custom-radial.svg +++ b/tests/testthat/_snaps/guide_axis_custom/guide-axis-base-radial.svg @@ -142,6 +142,6 @@ C bodywt awake -guide_axis_custom radial +guide_axis_base radial diff --git a/tests/testthat/_snaps/guide_axis_nested/guide-axis-nested-cartesian.svg b/tests/testthat/_snaps/guide_axis_nested/guide-axis-base-cartesian.svg similarity index 99% rename from tests/testthat/_snaps/guide_axis_nested/guide-axis-nested-cartesian.svg rename to tests/testthat/_snaps/guide_axis_nested/guide-axis-base-cartesian.svg index 5dee5bf..cce63e6 100644 --- a/tests/testthat/_snaps/guide_axis_nested/guide-axis-nested-cartesian.svg +++ b/tests/testthat/_snaps/guide_axis_nested/guide-axis-base-cartesian.svg @@ -105,6 +105,6 @@ r interaction(cyl, drv) hwy -guide_axis_nested cartesian +guide_axis_base cartesian diff --git a/tests/testthat/_snaps/guide_axis_nested/guide-axis-custom-radial.svg b/tests/testthat/_snaps/guide_axis_nested/guide-axis-base-radial.svg similarity index 99% rename from tests/testthat/_snaps/guide_axis_nested/guide-axis-custom-radial.svg rename to tests/testthat/_snaps/guide_axis_nested/guide-axis-base-radial.svg index 1398458..a95887c 100644 --- a/tests/testthat/_snaps/guide_axis_nested/guide-axis-custom-radial.svg +++ b/tests/testthat/_snaps/guide_axis_nested/guide-axis-base-radial.svg @@ -106,6 +106,6 @@ Bar interaction(cyl, drv) hwy -guide_axis_custom radial +guide_axis_base radial diff --git a/tests/testthat/test-compose-crux.R b/tests/testthat/test-compose-crux.R index bdb4710..05733a0 100644 --- a/tests/testthat/test-compose-crux.R +++ b/tests/testthat/test-compose-crux.R @@ -18,7 +18,7 @@ test_that("compose_crux can compose a legend", { legend.title = element_text(colour = col) ) compose_stack( - guide_axis_custom, + guide_axis_base, primitive_title(title = col), theme = theme ) diff --git a/tests/testthat/test-compose-ontop.R b/tests/testthat/test-compose-ontop.R index eb93ff3..5ee1a28 100644 --- a/tests/testthat/test-compose-ontop.R +++ b/tests/testthat/test-compose-ontop.R @@ -14,7 +14,7 @@ test_that("compose_ontop works as axis line", { top <- compose_stack( primitive_spacer(unit(0.25, "cm")), - guide_axis_custom( + guide_axis_base( key_manual(c(2.5, 3.5, 4.5, 5.5, 6.5, 15, 25, 35)), theme = theme( axis.ticks = element_line(colour = "tomato"), @@ -26,7 +26,7 @@ test_that("compose_ontop works as axis line", { ) ontop <- compose_ontop( - guide_axis_custom(), top + guide_axis_base(), top ) p <- base + diff --git a/tests/testthat/test-compose_sandwich.R b/tests/testthat/test-compose_sandwich.R index 74af9ee..17a4440 100644 --- a/tests/testthat/test-compose_sandwich.R +++ b/tests/testthat/test-compose_sandwich.R @@ -2,7 +2,7 @@ test_that("compose_sandwich can compose a legend", { sandwich <- compose_sandwich( middle = guide_colourbar(theme = theme(text = element_text(colour = "limegreen"))), - text = guide_axis_custom(theme = theme(text = element_text(colour = "tomato"))), + text = guide_axis_base(theme = theme(text = element_text(colour = "tomato"))), opposite = primitive_bracket(key = key_range_manual( c(10, 20), c(25, 30), c("A", "B") ), theme = theme(text = element_text(colour = "dodgerblue"))) diff --git a/tests/testthat/test-guide_axis_custom.R b/tests/testthat/test-guide_axis_custom.R index ba617f6..5953b60 100644 --- a/tests/testthat/test-guide_axis_custom.R +++ b/tests/testthat/test-guide_axis_custom.R @@ -1,12 +1,12 @@ -test_that("guide_axis_custom contains all primitive parameters", { - fmls <- fn_fmls_names(guide_axis_custom) +test_that("guide_axis_base contains all primitive parameters", { + fmls <- fn_fmls_names(guide_axis_base) expect_in(fn_fmls_names(primitive_line), fmls) expect_in(fn_fmls_names(primitive_labels), fmls) expect_in(fn_fmls_names(primitive_ticks), fmls) }) -test_that("guide_axis_custom looks good as axis", { +test_that("guide_axis_base looks good as axis", { base <- ggplot(msleep, aes(bodywt, awake)) + geom_blank() + @@ -21,23 +21,23 @@ test_that("guide_axis_custom looks good as axis", { ) p <- base + guides( - x = guide_axis_custom("log", angle = 0), - x.sec = guide_axis_custom("minor"), - y = guide_axis_custom(key = key_manual(c(5, 6, 7))), - y.sec = guide_axis_custom(key = key_manual(c(5, 20, 15), - label = c("A", "B", "C"))) + x = guide_axis_base("log", angle = 0), + x.sec = guide_axis_base("minor"), + y = guide_axis_base(key = key_manual(c(5, 6, 7))), + y.sec = guide_axis_base(key = key_manual(c(5, 20, 15), + label = c("A", "B", "C"))) ) - vdiffr::expect_doppelganger("guide_axis_custom cartesian", p) + vdiffr::expect_doppelganger("guide_axis_base cartesian", p) p <- base + coord_radial(start = 0.25 * pi, end = 1.75 * pi, inner.radius = 0.5) + guides( - theta = guide_axis_custom("log", angle = 0), - theta.sec = guide_axis_custom("minor"), - r = guide_axis_custom(key = key_manual(c(5, 7, 9)), angle = 0), - r.sec = guide_axis_custom(key = key_manual(c(5, 20, 15), + theta = guide_axis_base("log", angle = 0), + theta.sec = guide_axis_base("minor"), + r = guide_axis_base(key = key_manual(c(5, 7, 9)), angle = 0), + r.sec = guide_axis_base(key = key_manual(c(5, 20, 15), label = c("A", "B", "C"))) ) - vdiffr::expect_doppelganger("guide_axis_custom radial", p) + vdiffr::expect_doppelganger("guide_axis_base radial", p) }) diff --git a/tests/testthat/test-guide_axis_nested.R b/tests/testthat/test-guide_axis_nested.R index 0ee974d..712d0f9 100644 --- a/tests/testthat/test-guide_axis_nested.R +++ b/tests/testthat/test-guide_axis_nested.R @@ -19,7 +19,7 @@ test_that("guide_axis_nested logic works", { }) -test_that("guide_axis_custom looks good as axis", { +test_that("guide_axis_nested looks good as axis", { base <- ggplot(mpg, aes(interaction(cyl, drv), hwy)) + theme_test() + @@ -42,7 +42,7 @@ test_that("guide_axis_custom looks good as axis", { x.sec = guide_axis_nested(type = "box") ) - vdiffr::expect_doppelganger("guide_axis_nested cartesian", p) + vdiffr::expect_doppelganger("guide_axis_base cartesian", p) p <- base + coord_radial(start = 0.25 * pi, end = 1.75 * pi, inner.radius = 0.5) + @@ -59,5 +59,5 @@ test_that("guide_axis_custom looks good as axis", { theta.sec = guide_axis_nested(type = "box") ) - vdiffr::expect_doppelganger("guide_axis_custom radial", p) + vdiffr::expect_doppelganger("guide_axis_base radial", p) }) diff --git a/tests/testthat/test-guide_colour_ring.R b/tests/testthat/test-guide_colour_ring.R index 2478442..7dba2dc 100644 --- a/tests/testthat/test-guide_colour_ring.R +++ b/tests/testthat/test-guide_colour_ring.R @@ -13,7 +13,7 @@ test_that("guide_colring looks as it should", { legend.background = element_rect(colour = "limegreen") ) - outline <- compose_stack("axis_custom", primitive_line(theme = theme( + outline <- compose_stack("axis_base", primitive_line(theme = theme( legend.axis.line = element_line(colour = "dodgerblue") )), theme = theme(gguidance.guide.spacing = unit(0, "cm"))) diff --git a/vignettes/articles/guide_composition.Rmd b/vignettes/articles/guide_composition.Rmd index 95b0746..03f387e 100644 --- a/vignettes/articles/guide_composition.Rmd +++ b/vignettes/articles/guide_composition.Rmd @@ -42,7 +42,7 @@ For your regular axis guides for the `x` and `y` aesthetics, it works the same w However, if the guides it stacks supports other aesthetics, like `colour`, it can also be used there. ```{r} -staxis <- compose_stack("axis_custom", "axis_custom", "axis_custom") +staxis <- compose_stack("axis_base", "axis_base", "axis_base") standard + aes(colour = cty) + @@ -55,20 +55,20 @@ standard + ## Primitives -At this point, it might be wise to take a closer look at exactly what `guide_axis_custom()` is doing. +At this point, it might be wise to take a closer look at exactly what `guide_axis_base()` is doing. Once we pull on the threads on what its class is, the mystery starts to unravel: ```{r} -class(guide_axis_custom()) +class(guide_axis_base()) ``` -Indeed, by using `compose_stack("axis_custom", "axis_custom", ...)` we have been stacking a stack! -So when we peel back the layers and see what is inside `guide_axis_custom()`, will we find more stacks? -No, all good things must come to an end and so too must guides have their building blocks. +Indeed, by using `compose_stack("axis_base", "axis_base", ...)` we have been stacking a stack! +So when we peel back the layers and see what is inside `guide_axis_base()`, will we find more stacks? +No: all good things must come to an end and so too must guides have their building blocks. If the composition is the skeleton then these building blocks are the flesh providing function. These building blocks are called 'primitives' in gguidance. -For example, the `guide_axis_custom()` function is a stack of three primitives. +For example, the `guide_axis_base()` function is a stack of three primitives. They respectively build the axis line, the ticks and the labels. In the complete guide, they don't have any spacing between them, but let's exaggerate the spacing for clarity. @@ -96,7 +96,7 @@ range_key <- key_range_manual( ) standard + guides(x = compose_stack( - "axis_custom", + "axis_base", primitive_bracket(range_key, "curvy"), primitive_spacer(unit(0.5, "cm")), primitive_box(range_key), @@ -185,15 +185,15 @@ last_plot() + theme(legend.text.position = "left") ``` It should also be noted that if the guide has a label-supression mechanism, the 'opposite' guide will be drawn with surpressed labels. -The mechanism is in place in guides like `guide_axis()`/`guide_axis_custom()` for display in for example `facet_grid(axis.labels = "margins")`. +The mechanism is in place in guides like `guide_axis()`/`guide_axis_base()` for display in for example `facet_grid(axis.labels = "margins")`. -```{r, fig.keep = "last"}} +```{r, fig.keep = "last"} standard + aes(colour = cty) + scale_colour_viridis_c( guide = compose_sandwich( - text = "axis_custom", - opposite = "axis_custom" + text = "axis_base", + opposite = "axis_base" ) ) @@ -252,7 +252,7 @@ standard + aes(colour = cty) + guides( x = compose_stack("axis", my_gizmo), - colour = compose_sandwich(middle = my_gizmo, text = "axis_custom") + colour = compose_sandwich(middle = my_gizmo, text = "axis_base") ) ``` @@ -285,14 +285,14 @@ standard + option = "C", guide = compose_sandwich( middle = gizmo_density(just = 1), - text = "axis_custom" + text = "axis_base" ) ) + scale_fill_viridis_c( option = "D", guide = compose_sandwich( middle = gizmo_histogram(just = 0.5), - text = "axis_custom" + text = "axis_base" ) ) ``` @@ -304,7 +304,7 @@ The `compose_ontop()` guide lets you render one guide over the other. We can see in the plots below that it allows us to touch the panel when composing on top of one another, but not when stacking. ```{r} -top <- guide_axis_custom( +top <- guide_axis_base( key = key_manual(32, label = "Here is 32"), theme = theme_guide( ticks.length = unit(1.5, "cm"), @@ -337,7 +337,7 @@ standard + scale_colour_viridis_c( guide = compose_crux( centre = gizmo_barcap(), - left = "axis_custom", right = "axis_custom", + left = "axis_base", right = "axis_base", top = ball, bottom = block ) ) diff --git a/vignettes/articles/keys.Rmd b/vignettes/articles/keys.Rmd index 75d73dc..28abb8d 100644 --- a/vignettes/articles/keys.Rmd +++ b/vignettes/articles/keys.Rmd @@ -58,7 +58,7 @@ logkey <- key_log() ggplot(msleep, aes(sleep_total, brainwt, colour = bodywt)) + geom_point(na.rm = TRUE) + - scale_y_log10(guide = guide_axis_custom(key = logkey)) + + scale_y_log10(guide = guide_axis_base(key = logkey)) + scale_colour_viridis_c( trans = "log10", guide = guide_colbar(key = logkey) @@ -80,7 +80,7 @@ Most guides in gguidance accept a `key` argument, which will cause the guide to ```{r} my_key <- key_manual(aesthetic = c(2, 4, 6), label = c("two", "four", "six")) -standard + guides(x = guide_axis_custom(key = my_key)) +standard + guides(x = guide_axis_base(key = my_key)) ``` In addition, you can provide some automatic keys as keywords. @@ -88,7 +88,7 @@ Setting `key = "minor"`, is the same as setting `key = key_minor()`. In the same fashion many other `key_*()` functions can be used as keyword by omitting the `key_`-prefix. ```{r} -standard + guides(x = guide_axis_custom(key = "minor")) +standard + guides(x = guide_axis_base(key = "minor")) ``` Some keys don't directly return data frames, but return instructions on how these keys should interact with scales. @@ -198,7 +198,7 @@ Most key options have an `...` argument that allows many arguments to `element_t ```{r} ggplot(mpg, aes(displ, hwy)) + geom_point() + - guides(x = guide_axis_custom(key = key_auto(colour = "red", face = "bold"))) + guides(x = guide_axis_base(key = key_auto(colour = "red", face = "bold"))) ``` In some cases where you know the label in advance, which is almost every time one uses `key_manual()`, `key_map()` or their ranged equivalents, you can even vectorise these formatting options. @@ -229,7 +229,7 @@ You can see that `key_sequence()` does not produce an informative axis. ```{r} my_sequence_key <- key_sequence(n = 20) standard + - guides(x = guide_axis_custom(key = my_sequence_key)) + guides(x = guide_axis_base(key = my_sequence_key)) ``` The reason for this is that this key was designed for colour gradients diff --git a/vignettes/articles/tour.Rmd b/vignettes/articles/tour.Rmd index 2020d91..c60ae7e 100644 --- a/vignettes/articles/tour.Rmd +++ b/vignettes/articles/tour.Rmd @@ -24,7 +24,7 @@ Naturally, axes shine brightest as guides for positions like `x` and `y` but can ### Where (not) to apply -In gguidance, the staple axis is `guide_axis_custom()`. +In gguidance, the staple axis is `guide_axis_base()`. At a first glance, these axes are utterly unremarkable and very much mirror `ggplot2::guide_axis()` by design. ```{r} @@ -40,8 +40,8 @@ standard <- ggplot(mpg, aes(displ, hwy)) + ) standard + guides( - x = "axis_custom", - y = "axis_custom" + x = "axis_base", + y = "axis_base" ) ``` @@ -49,12 +49,12 @@ In terms of novelty, the only 'extra' option these axes offer is to display bidi ```{r} p <- standard + - scale_x_continuous(guide = guide_axis_custom(bidi = TRUE)) + - scale_y_continuous(guide = guide_axis_custom(bidi = TRUE)) + scale_x_continuous(guide = guide_axis_base(bidi = TRUE)) + + scale_y_continuous(guide = guide_axis_base(bidi = TRUE)) p ``` -However, `guide_axis_custom()` is more flexible than `ggplot2::guide_axis()`. +However, `guide_axis_base()` is more flexible than `ggplot2::guide_axis()`. In ggplot2, you'd typically have to switch to `ggplot2::guide_axis_theta()` to display an axis for the `theta` coordinate of a polar plot. The custom axis knows how to fit into polar coordinates, so no such fuss is needed when switching to polar coordinates. @@ -69,10 +69,10 @@ Why this unadvised yet possible is a topic that resurfaces later in this article ```{r} standard + aes(colour = cty) + - guides(colour = "axis_custom") + guides(colour = "axis_base") ``` -In summary, `guide_axis_custom()` is a flexible guide that can be used in any and all position aesthetic, and can (but should not) be used for other continuous aesthetics. +In summary, `guide_axis_base()` is a flexible guide that can be used in any and all position aesthetic, and can (but should not) be used for other continuous aesthetics. ### Nested axes @@ -385,7 +385,7 @@ standard + scale_colour_viridis_c( minor_breaks = breaks_width(1), guide = guide_colbar( - first_guide = guide_axis_custom("minor"), + first_guide = guide_axis_base("minor"), second_guide = brackets ) ) @@ -454,7 +454,7 @@ housing + colours = periodic_pal, limits = c(1, 13), breaks = 1:12, minor_breaks = breaks_width(0.25), guide = guide_colring( - outer_guide = guide_axis_custom("minor"), + outer_guide = guide_axis_base("minor"), inner_guide = "none" ) ) +