What does autoplot.microbenchmark actually plot?

前端 未结 1 1351
轮回少年
轮回少年 2021-02-19 00:17

According to the docs, microbenchmark:::autoplot \"Uses ggplot2 to produce a more legible graph of microbenchmark timings.\"

Cool! Let\'s try the example co

相关标签:
1条回答
  • 2021-02-19 00:22

    The short answer is a violin plot:

    It is a box plot with a rotated kernel density plot on each side.


    The longer more interesting(?) answer. When you call the autoplot function, you are actually calling

    ## class(ts) is microbenchmark
    autoplot.microbenchmark
    

    We can then inspect the actual function call via

    R> getS3method("autoplot", "microbenchmark")
    function (object, ..., log = TRUE, y_max = 1.05 * max(object$time)) 
    {
        y_min <- 0
        object$ntime <- convert_to_unit(object$time, "t")
        plt <- ggplot(object, ggplot2::aes_string(x = "expr", y = "ntime"))
     ## Another ~6 lines or so after this
    

    The key line is + stat_ydensity(). Looking at ?stat_ydensity you come to the help page on violin plots.

    0 讨论(0)
提交回复
热议问题