totalplot<-cowplot::plot_grid(plotlist=plotlist,ncol=1) Error in `geom_line()`: ! Problem while computing aesthetics. ℹ Error occurred in the 2nd layer. Caused by error in `FUN()`: ! object 'EMD' not found Run `rlang::last_trace()` to see where the error occurred.
时间: 2024-04-28 10:21:55 浏览: 14
根据错误提示,似乎出现了一个"EMD not found" 的错误,可能是由于没有加载或者创建 `EMD` 对象。你需要检查一下代码中是否有创建 `EMD` 对象的语句,或者在运行这段代码之前是否已经加载了包含 `EMD` 对象的数据或者文件。同时,你也可以运行 `rlang::last_trace()` 命令来查看更详细的错误信息,以便更好地定位问题所在。
相关问题
Backtrace: ▆ 1. └─cowplot::plot_grid(plotlist = plotlist, ncol = 1) 2. └─cowplot::align_plots(...) 3. └─base::lapply(...) 4. └─cowplot (local) FUN(X[[i]], ...) 5. ├─cowplot::as_gtable(x) 6. └─cowplot:::as_gtable.default(x) 7. ├─cowplot::as_grob(plot) 8. └─cowplot:::as_grob.ggplot(plot) 9. └─ggplot2::ggplotGrob(plot) 10. ├─ggplot2::ggplot_gtable(ggplot_build(x)) 11. │ └─ggplot2:::attach_plot_env(data$plot$plot_env) 12. │ └─base::options(ggplot2_plot_env = env) 13. ├─ggplot2::ggplot_build(x) 14. └─ggplot2:::ggplot_build.ggplot(x) 15. └─ggplot2:::by_layer(...) 16. ├─rlang::try_fetch(...) 17. │ ├─base::tryCatch(...) 18. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers) 19. │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) 20. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler) 21. │ └─base::withCallingHandlers(...) 22. └─ggplot2 (local) f(l = layers[[i]], d = data[[i]]) 23. └─l$compute_aesthetics(d, plot) 24. └─ggplot2 (local) compute_aesthetics(..., self = self) 25. └─base::lapply(aesthetics, eval_tidy, data = data, env = env) 26. └─rlang (local) FUN(X[[i]], ...)
根据你提供的 `Backtrace` 信息,可以看出问题出在 `cowplot::plot_grid()` 函数中,具体是在运行 `cowplot::align_plots()` 函数时出现了问题。在 `align_plots()` 函数中,使用 `lapply()` 函数对 `plotlist` 中的每个元素应用了一个函数,但是这个函数中可能出现了一些错误。你需要检查一下自己的代码中是否有对 `plotlist` 进行了修改或者处理,导致其中的元素出现了错误,或者尝试使用 `rlang::last_trace()` 命令来查看更详细的错误信息,以便更好地定位问题所在。
p_wh <- get_wh(plot = p, unit = "in")
这段代码的作用是获取一个 ggplot2 绘图对象的宽度和高度,单位为英寸(inches)。
具体来说,`get_wh()` 函数是由 `cowplot` 包提供的一个帮助函数,用于获取绘图对象的宽度和高度。在这个代码中,函数的参数 `plot` 指定了要获取宽度和高度的绘图对象,而 `unit` 参数指定了返回值的单位,这里是英寸。
这个代码段的运行结果会将绘图对象的宽度和高度以一个列表的形式返回,并且单位为英寸。可以将返回的列表赋值给一个变量,以便后续的使用。例如:
```
p_wh <- get_wh(plot = p, unit = "in")
width <- p_wh[[1]]
height <- p_wh[[2]]
```