Skip to content

Commit

Permalink
fix bug (drawsim has no xlim when all spp are extant)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjanuario committed Aug 4, 2023
1 parent ea94977 commit 3d501e6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion R/draw.sim.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,18 @@ draw.sim <- function (sim, fossils = NULL, sortBy = "TS",

# limits in x axis (to enclose all species' durations)
if (!("xlim" %in% names(args))) {

# warnings are not relevant here:
suppressWarnings({
min_time = min(sim$SIM$TE, na.rm = TRUE)
})
# if all species are extant, min_time must be adjusted:
if(!is.finite(min_time)){
min_time = 0
}

formals(plot.default)$xlim <-
c(max(sim$TS, na.rm = TRUE), min(sim$TE, na.rm = TRUE) - 1)
c(max(sim$SIM$TS, na.rm = TRUE), min_time - 1)
}

# limits in y axis
Expand Down

0 comments on commit 3d501e6

Please sign in to comment.