## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----out.width='90%', fig.width=7, fig.height=5-------------------------------
library(ggplot2)
speed_out = readRDS(system.file("extdata", "rtrees_speed_out.rds", package = "rtrees"))
speed_out = dplyr::mutate(speed_out, n_sp_missing_k = n_sp_missing / 1000, time_s = time/1e9)
# speed_lm = dplyr::group_by(speed_out, expr) |> 
#   dplyr::do(broom::tidy(lm(time_s ~ n_sp_missing_k, data = .))) |> 
#   dplyr::ungroup()
ggplot(speed_out, aes(x = n_sp_missing_k, y = time_s, color = expr, group = expr)) +
  geom_point() +
  geom_smooth(method = "lm") +
  labs(x = "Number of binding species (Thousand)",
       y = "Time (Second)", color = NULL, group = NULL) +
  scale_x_continuous(breaks = c(0.05, seq(0.5, 5, 0.5))) +
  scale_y_continuous(breaks = c(0, 10, seq(25, 200, 25))) +
  geom_text(x = 4, y = 30, label = "rtrees: y = 0.35+ 0.95x", inherit.aes = FALSE, color = "#F8766D") +
  geom_text(x = 1.8, y = 150, label = "V.PhyloMaker2: y = 12.3 + 36.8x", inherit.aes = FALSE, color = "#00BFC4") +
  theme(legend.position = "none") 

