Skip to content

Commit f1b2414

Browse files
teunbrandEnchufa2
andauthored
Retire GeomErrorbarh (#63)
* swap `GeomErrobarh` for `GeomErrobar` with y-orientation * minor adjustments + update NEWS --------- Co-authored-by: Iñaki Úcar <[email protected]>
1 parent 2b4e82c commit f1b2414

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ URL: https://r-quantities.github.io/errors/, https://github.com/r-quantities/err
1818
BugReports: https://github.com/r-quantities/errors/issues
1919
LazyData: true
2020
Depends: R (>= 3.0.0)
21-
Suggests: dplyr (>= 1.0.0), vctrs (>= 0.5.0), pillar, ggplot2 (>= 3.4.0),
21+
Suggests: dplyr (>= 1.0.0), vctrs (>= 0.5.0), pillar, ggplot2 (>= 3.5.0),
2222
testthat, vdiffr, knitr, rmarkdown
2323
RoxygenNote: 7.3.2
2424
Roxygen: list(old_usage = TRUE)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# errors devel
22

33
- Improve `cbind` arg name deparsing.
4+
- Switch from `geom_errobarh()` (deprecated) to `geom_errorbar()` with flipped
5+
aesthetics in `geom_errors()` (#63).
46

57
# errors 0.4.3
68

R/geom_errors.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ MakeGeomErrors <- function() ggplot2::ggproto(
104104
data$xmax_bars <- data$xmax
105105
data$ymin <- data$ymax <- NULL
106106

107+
params$flipped_aes <- TRUE
108+
params$width <- params$height
107109
data$xmin <- data$xmin_errors
108110
data$xmax <- data$xmax_errors
109-
data <- ggplot2::GeomErrorbarh$setup_data(data, params)
111+
data <- ggplot2::GeomErrorbar$setup_data(data, params)
110112
data$ymin_bars <- data$ymin
111113
data$ymax_bars <- data$ymax
112114
data$xmin <- data$xmax <- NULL
@@ -137,8 +139,8 @@ MakeGeomErrors <- function() ggplot2::ggproto(
137139
data$xmax <- data$xmax_errors
138140
data$ymin <- data$ymin_bars
139141
data$ymax <- data$ymax_bars
140-
grob <- append(grob, list(ggplot2::GeomErrorbarh$draw_panel(
141-
data, panel_params, coord=coord, height=height)))
142+
grob <- append(grob, list(ggplot2::GeomErrorbar$draw_panel(
143+
data, panel_params, coord=coord, width=height, flipped_aes = TRUE)))
142144
}
143145
grob <- do.call(grid::grobTree, grob)
144146
grob$name <- grid::grobName(grob, "geom_errors")

tests/testthat/test-plot.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ test_that("ggplot2 plots work as expected", suppressWarnings({
2727
iris.e[1:4] <- lapply(iris.e[1:4], function(x) set_errors(x, x*0.02))
2828

2929
p0 <- ggplot(iris.e) + aes(Sepal.Length, Sepal.Width, color=Species) +
30-
geom_point() + theme_bw() + theme(legend.position=c(0.6, 0.8))
30+
geom_point() + theme_bw() +
31+
theme(legend.position="inside", legend.position.inside=c(0.6, 0.8))
3132
p1 <- p0 +
3233
geom_errorbar(aes(ymin=errors_min(Sepal.Width), ymax=errors_max(Sepal.Width))) +
33-
geom_errorbarh(aes(xmin=errors_min(Sepal.Length), xmax=errors_max(Sepal.Length)))
34+
geom_errorbar(aes(xmin=errors_min(Sepal.Length), xmax=errors_max(Sepal.Length)))
3435
p2 <- p0 + geom_errors()
3536
p3 <- p0 + geom_errors(aes(x=drop_errors(Sepal.Length)))
3637
p4 <- p0 + geom_errors(aes(y=drop_errors(Sepal.Width)))

vignettes/rjournal.Rmd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ legend(6.2, 4.4, unique(iris.e[["Species"]]),
246246
library(ggplot2)
247247
248248
ggplot(iris.e) + aes(Sepal.Length, Sepal.Width, color=Species) +
249-
geom_point() + geom_errors() + theme_bw() + theme(legend.position=c(0.6, 0.8))
249+
geom_point() + geom_errors() + theme_bw() +
250+
theme(legend.position="inside", legend.position.inside=c(0.6, 0.8))
250251
```
251252

252253
```{r plot, echo=FALSE, out.width='100%', fig.height=3.5, fig.width=10, fig.cap=paste0(label("fig:plot"), "Base plot with error bars (left) and ggplot2's version (right).")}
@@ -259,7 +260,8 @@ legend(6.2, 4.4, unique(iris.e[["Species"]]),
259260
library(ggplot2)
260261
261262
p <- ggplot(iris.e) + aes(Sepal.Length, Sepal.Width, color=Species) +
262-
geom_point() + geom_errors() + theme_bw() + theme(legend.position=c(0.6, 0.8))
263+
geom_point() + geom_errors() + theme_bw() +
264+
theme(legend.position="inside", legend.position.inside=c(0.6, 0.8))
263265
264266
plot.new()
265267
fig <- par("fig")

0 commit comments

Comments
 (0)