Skip to content

Commit dc51758

Browse files
authored
Replace label functions (#557)
* swap out `xlab()`/`ylab()` for `labs()` * replace `ggtitle()` * S3 method consistency
1 parent 90c9198 commit dc51758

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

NAMESPACE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ importFrom(ggplot2,geom_rect)
7777
importFrom(ggplot2,geom_vline)
7878
importFrom(ggplot2,ggplot)
7979
importFrom(ggplot2,ggplot_add)
80-
importFrom(ggplot2,ggtitle)
81-
importFrom(ggplot2,xlab)
82-
importFrom(ggplot2,ylab)
80+
importFrom(ggplot2,labs)
8381
importFrom(glue,glue)
8482
importFrom(glue,glue_collapse)
8583
importFrom(magrittr,"%>%")

R/visualize.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ ggplot2::ggplot_add
170170
#' vignette("infer")
171171
#' }
172172
#'
173-
#' @importFrom ggplot2 ggplot geom_histogram aes ggtitle
174-
#' @importFrom ggplot2 xlab ylab geom_vline geom_rect geom_bar
173+
#' @importFrom ggplot2 ggplot geom_histogram aes
174+
#' @importFrom ggplot2 geom_vline geom_rect geom_bar labs
175175
#' @importFrom stats dt qt df qf dnorm qnorm dchisq qchisq
176176
#' @export
177177
visualize <- function(
@@ -651,7 +651,7 @@ redraw_theory_layer <- function(plot, mean_shift, sd_shift) {
651651
}
652652

653653

654-
title_layer <- function(data, title_fn = ggplot2::ggtitle) {
654+
title_layer <- function(data, title_fn = function(x) labs(title = x)) {
655655
method <- get_viz_method(data)
656656
theory_type <- short_theory_type(data)
657657

@@ -691,9 +691,9 @@ labels_layer <- function(data, term) {
691691
x_lab <- switch(method, simulation = "{term}", "{theory_type} stat")
692692
y_lab <- switch(method, simulation = "count", "density")
693693

694-
list(
695-
xlab(glue(x_lab, .null = "NULL")),
696-
ylab(glue(y_lab, .null = "NULL"))
694+
labs(
695+
x = glue(x_lab, .null = "NULL"),
696+
y = glue(y_lab, .null = "NULL")
697697
)
698698
}
699699

@@ -749,7 +749,7 @@ get_viz_bins <- function(data) {
749749

750750
#' @method ggplot_add infer_layer
751751
#' @export
752-
ggplot_add.infer_layer <- function(object, plot, object_name) {
752+
ggplot_add.infer_layer <- function(object, plot, ...) {
753753
# a method for the `+` operator for infer objects.
754754
# - "object to add" (arguments to the RHS of the `+`)
755755
# - plot is the existing plot (on the LHS of the `+`)

0 commit comments

Comments
 (0)