Skip to content

Commit a7c282c

Browse files
authored
return unmodified plot with shade_*(NULL) (#567)
1 parent 62298fc commit a7c282c

File tree

5 files changed

+153
-4
lines changed

5 files changed

+153
-4
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# infer (development version)
22

3+
* Fixed bug where adding `shade_confidence_interval(NULL)` or `shade_p_value(NULL)`
4+
to plots resulted in `list()` rather than the unmodified plot (#566).
5+
36
* Introduced support for arbitrary test statistics in `calculate()`. In addition
47
to the pre-implemented `calculate(stat)` options, taken as strings, users can
58
now supply a function defining any scalar-valued test statistic. See

R/shade_confidence_interval.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,12 @@ shade_confidence_interval_term <- function(
162162
endpoints <- impute_endpoints(endpoints, plot, call = call)
163163
check_shade_confidence_interval_args(color, fill)
164164

165-
res <- list()
166165
if (is.null(endpoints)) {
167-
return(res)
166+
return(plot)
168167
}
169168

169+
res <- list()
170+
170171
if (!is.null(fill)) {
171172
# Making extra step of precomputing arguments in order to have default value
172173
# of `alpha = 0.6` overwritable in `...`

R/shade_p_value.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,12 @@ shade_p_value_term <- function(
168168

169169
term <- x_axis_label(plot)
170170

171-
res <- list()
172171
if (is.null(obs_stat)) {
173-
return(res)
172+
return(plot)
174173
}
175174

175+
res <- list()
176+
176177
# Add shading
177178
if (!is.null(direction) && !is.null(fill)) {
178179
if (direction %in% c("less", "left", "greater", "right")) {
Lines changed: 72 additions & 0 deletions
Loading
Lines changed: 72 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)