Skip to content

Commit

Permalink
Passing xlim and ylim arguments to the plot.zcurve() function
Browse files Browse the repository at this point in the history
  • Loading branch information
FBartos committed Jan 7, 2022
1 parent 2d71bfb commit 6d12432
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: zcurve
Title: An Implementation of Z-Curves
Version: 2.1.0
Version: 2.1.1
Authors@R: c(
person("František", "Bartoš", email = "f.bartos96@gmail.com", role = c("aut", "cre")),
person("Ulrich", "Schimmack", email = "ulrich.schimmack@utoronto.ca", role = c("aut")))
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## version 2.1.1
- Allowing to pass the xlim and ylim arguments to the z-curve plot function.

## version 2.1.0
- Adding 'zcurve_data' function to transform different tests statistics into a z-curve data object.

Expand Down
34 changes: 29 additions & 5 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ print.summary.zcurve <- function(x, ...){
#' of annotations relative to the figure's width.
#' @param cex.anno A number specifying the size of the annotation text.
#' @param ... Additional arguments including \code{main}, \code{xlab},
#' \code{ylab}, \code{cex.axis}, \code{cex.lab}
#' \code{ylab}, \code{xlim}, \code{ylim}, \code{cex.axis}, \code{cex.lab}
#'
#' @method plot zcurve
#' @export plot.zcurve
Expand Down Expand Up @@ -577,6 +577,16 @@ plot.zcurve <- function(x, annotation = FALSE, CI = FALSE, extrapolate
}else{
ylab <- additional$ylab
}
if(is.null(additional$xlim)){
xlim <- NULL
}else{
xlim <- additional$xlim
}
if(is.null(additional$ylim)){
ylim <- NULL
}else{
ylim <- additional$ylim
}
if(is.null(additional$cex.axis)){
cex.axis <- 1
}else{
Expand Down Expand Up @@ -666,11 +676,25 @@ plot.zcurve <- function(x, annotation = FALSE, CI = FALSE, extrapolate
}


# overwrite xmin, xmax, ymin, ymax if xlim and ylim are specified
if(!is.null(ylim)){
y_min <- ylim[1]
y_max <- ylim[2]
}else{
y_min <- 0
}
if(!is.null(xlim)){
x_min <- xlim[1]
x_max <- xlim[2]
}else{
x_min <- 0
}

# plot z-scores used for fitting
graphics::plot(h1,
freq = FALSE, density = 0, angle = 0, border = "blue",
xlim = c(0, x_max),
ylim = c(0, y_max),
xlim = c(x_min, x_max),
ylim = c(y_min, y_max),
ylab = ylab,
xlab = xlab,
main = main,
Expand All @@ -682,8 +706,8 @@ plot.zcurve <- function(x, annotation = FALSE, CI = FALSE, extrapolate
graphics::par(new=TRUE)
graphics::plot(h2,
freq = FALSE, density = 0, angle = 0, border ="grey30",
xlim = c(0, x_max),
ylim = c(0, y_max),
xlim = c(x_min, x_max),
ylim = c(y_min, y_max),
axes = FALSE, ann = FALSE, lwd = 1, las = 1)
}
# add the density estimate if the model was estimated by density
Expand Down
2 changes: 1 addition & 1 deletion man/plot.zcurve.Rd

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

0 comments on commit 6d12432

Please sign in to comment.