Skip to content

Commit

Permalink
Avoid transparent legend in funnel().
Browse files Browse the repository at this point in the history
  • Loading branch information
wviechtb committed Aug 28, 2023
1 parent d60d4dd commit cad690b
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 28 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: metafor
Version: 4.3-12
Date: 2023-08-18
Date: 2023-08-28
Title: Meta-Analysis Package for R
Authors@R: person(given = "Wolfgang", family = "Viechtbauer", role = c("aut","cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-3463-4063"))
Depends: R (>= 4.0.0), methods, Matrix, metadat, numDeriv
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# metafor 4.3-12 (2023-08-18)
# metafor 4.3-12 (2023-08-28)

- added `getmfopt()` and `setmfopt()` functions for getting and setting package options and made some of the options more flexible

Expand Down
27 changes: 17 additions & 10 deletions R/funnel.default.r
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ label=FALSE, offset=0.4, legend=FALSE, ...) {
if (!is.null(ddd$transf))
warning("Function does not have a 'transf' argument (use 'atransf' instead).", call.=FALSE, immediate.=TRUE)

lplot <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) plot(...)
labline <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) abline(...)
lsegments <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) segments(...)
laxis <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) axis(...)
lpolygon <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) polygon(...)
llines <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) lines(...)
lpoints <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) points(...)
lrect <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) rect(...)
ltext <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) text(...)
lplot <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) plot(...)
labline <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) abline(...)
lsegments <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) segments(...)
laxis <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) axis(...)
lpolygon <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) polygon(...)
llines <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) lines(...)
lpoints <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) points(...)
lrect <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) rect(...)
ltext <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) text(...)

### refline2, level2, and lty2 for adding a second reference line / funnel

Expand Down Expand Up @@ -262,6 +262,13 @@ label=FALSE, offset=0.4, legend=FALSE, ...) {
colbox <- .coladj(par("bg","fg"), dark=0.6, light=-0.6)
}

if (!is.null(ddd$lgndbg)) {
lgndbg <- ddd$lgndbg
} else {
#lgndbg <- par("bg")
lgndbg <- .coladj(par("bg","fg"), dark=0.01, light=-0.01) # need to adjust slightly to avoid a transparent background
}

#########################################################################

### if a subset of studies is specified
Expand Down Expand Up @@ -702,7 +709,7 @@ label=FALSE, offset=0.4, legend=FALSE, ...) {
pt.bg <- c(pt.bg, bg[1])
}

legend(lpos, inset=.01, bg=par("bg"), pch=pch.l, col=col.l, pt.cex=pt.cex, pt.bg=pt.bg, legend=ltxt)
legend(lpos, inset=.01, bg=lgndbg, pch=pch.l, col=col.l, pt.cex=pt.cex, pt.bg=pt.bg, legend=ltxt)
#legend(lpos, inset=.01, bg=.coladj(par("bg","fg"), dark=0.05, light=-0.05), pch=pch.l, col=col.l, pt.cex=pt.cex, pt.bg=pt.bg, legend=ltxt)

}
Expand Down
29 changes: 19 additions & 10 deletions R/funnel.rma.r
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ label=FALSE, offset=0.4, legend=FALSE, ...) {
if (missing(hlines))
hlines <- par("bg")

#print(c(back=back, shade=shade, hlines=hlines))

if (missing(pch)) {
pch <- 19
} else {
Expand Down Expand Up @@ -203,15 +205,15 @@ label=FALSE, offset=0.4, legend=FALSE, ...) {
if (!is.null(ddd$transf))
warning("Function does not have a 'transf' argument (use 'atransf' instead).", call.=FALSE, immediate.=TRUE)

lplot <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) plot(...)
labline <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) abline(...)
lsegments <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) segments(...)
laxis <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) axis(...)
lpolygon <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) polygon(...)
llines <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) lines(...)
lpoints <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) points(...)
lrect <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) rect(...)
ltext <- function(..., refline2, level2, lty2, colci, colref, colbox, transf, ci.res) text(...)
lplot <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) plot(...)
labline <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) abline(...)
lsegments <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) segments(...)
laxis <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) axis(...)
lpolygon <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) polygon(...)
llines <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) lines(...)
lpoints <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) points(...)
lrect <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) rect(...)
ltext <- function(..., refline2, level2, lty2, colci, colref, colbox, lgndbg, transf, ci.res) text(...)

### refline2, level2, and lty2 for adding a second reference line / funnel

Expand Down Expand Up @@ -261,6 +263,13 @@ label=FALSE, offset=0.4, legend=FALSE, ...) {
colbox <- .coladj(par("bg","fg"), dark=0.6, light=-0.6)
}

if (!is.null(ddd$lgndbg)) {
lgndbg <- ddd$lgndbg
} else {
#lgndbg <- par("bg")
lgndbg <- .coladj(par("bg","fg"), dark=0.01, light=-0.01) # need to adjust slightly to avoid a transparent background
}

#########################################################################

### get values for the x-axis (and corresponding vi, sei, and ni values)
Expand Down Expand Up @@ -755,7 +764,7 @@ label=FALSE, offset=0.4, legend=FALSE, ...) {
pt.bg <- c(pt.bg, bg[2])
}

legend(lpos, inset=.01, bg=par("bg"), pch=pch.l, col=col.l, pt.cex=pt.cex, pt.bg=pt.bg, legend=ltxt)
legend(lpos, inset=.01, bg=lgndbg, pch=pch.l, col=col.l, pt.cex=pt.cex, pt.bg=pt.bg, legend=ltxt)
#legend(lpos, inset=.01, bg=.coladj(par("bg","fg"), dark=0.05, light=-0.05), pch=pch.l, col=col.l, pt.cex=pt.cex, pt.bg=pt.bg, legend=ltxt)

}
Expand Down
2 changes: 1 addition & 1 deletion R/plot.profile.rma.r
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plot.profile.rma <- function(x, xlim, ylim, pch=19, xlab, ylab, main, refline=TR
### filter out some arguments for the plot() function

lplot <- function(..., time, LB, startmethod, sub1) plot(...)
lpoints <- function(..., time, LB, startmethod, sub1, log) points(...)
lpoints <- function(..., time, LB, startmethod, sub1, log) points(...) # need 'log' here so profile(res, log="x") doesn't throw a warning

#########################################################################

Expand Down
2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pkgdown: 2.0.7
pkgdown_sha: ~
articles:
diagram: pkgdown/diagram.html
last_built: 2023-08-18T14:42Z
last_built: 2023-08-28T13:11Z
urls:
reference: https://wviechtb.github.io/metafor/reference
article: https://wviechtb.github.io/metafor/articles
Expand Down
Binary file modified docs/reference/Rplot002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/reference/formula.rma.html

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

Binary file modified docs/reference/funnel-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/funnel-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/reference/reporter.html

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

Binary file modified docs/reference/trimfill-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/trimfill-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cad690b

Please sign in to comment.