Skip to content

idd-unit/fastribbon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastribbon

This package includes a C++ implementation of ggdist's line-ribbon plot optimized for large numbers (thousands) of high-resolution time-series trajectories.

One function is included: stat_fastribbon

library(fastribbon)

df <- expand_grid(x = seq(0, 100, by = 0.1), y = rep(0, 1000)) |> 
  mutate(y = rnorm(n(), cos(x / 10) * 1, 1.5 + sin(x / 10)))

ggplot(df) +
  stat_fastribbon(aes(x = x, y = y)) +
  
  scale_fill_brewer() +
  
  theme_bw()
image

Simple benchmark results

Plotting df above is ~40x faster using stat_fastribbon:

p_custom <- ggplot(df, aes(x, y)) + stat_fastribbon() + scale_fill_brewer()
p_base <- ggplot(df, aes(x, y)) + stat_lineribbon() + scale_fill_brewer()

bench::mark(
  custom = ggplot_build(p_custom),
  base   = ggplot_build(p_base),
  check  = FALSE, 
  iterations = 10
)

# A tibble: 2 × 13
  expression      min   median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc total_time result memory                   time            gc      
  <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl> <int> <dbl>   <bch:tm> <list> <list>                   <list>          <list>  
1 custom      547.9ms  598.3ms    1.13    540.05MB     4.06    10    36      8.86s <NULL> <Rprofmem [525 × 3]>     <bench_tm [10]> <tibble>
2 base          18.4s    20.1s    0.0492    3.39GB     1.29    10   263      3.39m <NULL> <Rprofmem [472,978 × 3]> <bench_tm [10]> <tibble>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors