bri*_*tar 16 plot r microbenchmark ggplot2
根据文档,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)
Run Code Online (Sandbox Code Playgroud)
我没有看到任何关于...文档中的软弱起伏,但是我从功能创建者的这个答案中得到的最好的猜测是,这就像一个平滑的系列时间表的箱形图,上下都是四分相连接在形状的主体上.也许?这些情节看起来太有趣了,不知道这里发生了什么.
这是一个情节是什么?
简短的回答是小提琴情节:
它是一个箱形图,每侧都有一个旋转的核密度图.
更有趣(?)的答案越长.当您调用该autoplot
函数时,您实际上正在调用
## class(ts) is microbenchmark
autoplot.microbenchmark
Run Code Online (Sandbox Code Playgroud)
然后我们可以检查实际的函数调用
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
Run Code Online (Sandbox Code Playgroud)
关键是+ stat_ydensity()
.看着?stat_ydensity
你来到小提琴情节的帮助页面.
归档时间: |
|
查看次数: |
1308 次 |
最近记录: |