根据文档,microbenchmark:::autoplot
“使用 ggplot2 生成更清晰的微基准计时图表。”
酷!让我们尝试一下示例代码:
library("ggplot2")
tm <- microbenchmark(rchisq(100, 0),
rchisq(100, 1),
rchisq(100, 2),
rchisq(100, 3),
rchisq(100, 5), times=1000L)
autoplot(tm)
我在文档中没有看到任何关于......柔软的波动的信息,但我的最佳猜测来自 this answer by the function creator这就像一系列平滑的运行时间箱线图,上四分位数和下四分位数连接在形状的主体上。或许?这些情节看起来太有趣了,不去看看这里发生了什么。
这是一个什么情节?
最佳答案
简短的答案是 violin plot :
<小时/>It is a box plot with a rotated kernel density plot on each side.
答案越长越有趣(?)。当您调用 autoplot
函数时,您实际上是在调用
## class(ts) is microbenchmark
autoplot.microbenchmark
然后我们可以通过检查实际的函数调用
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
关键行是+ stat_y密度()
。看看?stat_y密度
你
访问 fiddle 图的帮助页面。
关于r - autoplot.microbenchmark 实际绘制了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24451575/