Skip to content

Commit

Permalink
Rename guide_axis_custom() to guide_axis_base() (#24)
Browse files Browse the repository at this point in the history
* rename function

* rename inside other functions

* rename in tests

* accept snapshots

* adapt additional documentation

* fix typo
  • Loading branch information
teunbrand authored Oct 8, 2024
1 parent 1e9a9cc commit 7ced72e
Show file tree
Hide file tree
Showing 30 changed files with 103 additions and 103 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions R/compose-ontop.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion R/compose-sandwich.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
#' ))
Expand Down
8 changes: 4 additions & 4 deletions R/guide_axis_custom.R → R/guide_axis_base.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion R/guide_colbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions R/guide_colring.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions R/guide_colsteps.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -68,7 +68,7 @@ base +
guide = "colbar"
) +
guides(
x = guide_axis_custom(bidi = TRUE)
x = guide_axis_base(bidi = TRUE)
)
```

Expand Down Expand Up @@ -103,7 +103,7 @@ base +
scale_colour_viridis_c(
guide = compose_sandwich(
middle = gizmo_density(),
text = "axis_custom",
text = "axis_base",
opposite = efficient_bracket
)
)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -63,7 +63,7 @@ base +
guide = "colbar"
) +
guides(
x = guide_axis_custom(bidi = TRUE)
x = guide_axis_base(bidi = TRUE)
)
```

Expand Down Expand Up @@ -106,7 +106,7 @@ base +
scale_colour_viridis_c(
guide = compose_sandwich(
middle = gizmo_density(),
text = "axis_custom",
text = "axis_base",
opposite = efficient_bracket
)
)
Expand Down
4 changes: 2 additions & 2 deletions man/compose_ontop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/compose_sandwich.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions man/guide_axis_custom.Rd → man/guide_axis_base.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/guide_axis_nested.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/guide_colbar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/guide_colring.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/guide_colsteps.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/testthat/test-compose-crux.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-compose-ontop.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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 +
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-compose_sandwich.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
Loading

0 comments on commit 7ced72e

Please sign in to comment.