Skip to content

Commit

Permalink
Merge pull request #65 from joshwlambert/richel
Browse files Browse the repository at this point in the history
Use correct X axis
  • Loading branch information
joshwlambert committed Jan 24, 2022
2 parents f5daace + 648c944 commit c61194d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
11 changes: 6 additions & 5 deletions R/plot_daisie_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ plot_daisie_data <- function(daisie_data) {
t <- DAISIEmainland::daisie_data_to_tables(daisie_data)

p <- ggplot2::ggplot(t$colonists_general) +
ggplot2::scale_x_continuous(
name = "Time",
limits = c(0, t$header$island_age)
) + ggplot2::theme(
ggplot2::scale_x_reverse(
name = "Time before present",
limits = c(t$header$island_age, 0)
) +
ggplot2::theme(
axis.title.y = ggplot2::element_blank(),
axis.text.y = ggplot2::element_blank(),
axis.ticks.y = ggplot2::element_blank()
Expand Down Expand Up @@ -126,7 +127,7 @@ plot_daisie_data <- function(daisie_data) {
ggplot2::aes(
x = branching_times,
y = y,
xend = t$header$island_age,
xend = 0,
yend = y,
color = stac_str
)
Expand Down
30 changes: 30 additions & 0 deletions tests/testthat/test-plot_daisie_mainland_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,33 @@ test_that("many clades", {
)
plot_daisie_mainland_data(daisie_mainland_data, replicate_index = 1)
})

test_that("Issue 64: use time before present", {

# The Endemic_singleton_MaxAge island species are plotted near
# the edge of the plot but they should have the longest line.
# This makes me think that the plot_daisie_mainland_data function
# should plot "Time before present" on the x-axis.
set.seed(
1,
kind = "Mersenne-Twister",
normal.kind = "Inversion",
sample.kind = "Rejection"
)

daisie_mainland_data <- DAISIEmainland::sim_island_with_mainland(
total_time = 1,
m = 100,
island_pars = c(1.0, 0.5, 10, 0.1, 0.5),
mainland_ex = 2,
mainland_sample_prob = 1,
mainland_sample_type = "complete",
replicates = 1,
verbose = FALSE
)

DAISIEmainland::plot_daisie_mainland_data(
daisie_mainland_data = daisie_mainland_data,
replicate_index = 1
)
})

0 comments on commit c61194d

Please sign in to comment.