在 R 中组合图

编程入门 行业动态 更新时间:2024-10-10 21:24:45
本文介绍了在 R 中组合图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有几个图想将它们组合在一起并为组合图添加标题,但不知何故我无法使用 R 组合它们.(使用 RStudio)

I have several plots that I want to combine them together and add a title to the combined plot, but somehow I cannot combine them using R. (using RStudio)

  • 组合使用 plot(resid(lme)) 绘制的两个残差图,其中 lme 是线性混合模型.
  • 合并使用 interaction.plot(x1,x2,y) 绘制的两个交互图,其中 x1 和 x2 是两个自变量,y 是因变量.
  • Combine two residual plots plotted by using plot(resid(lme)) where lme is a linear mixed model.
  • Combine two interaction plots plotted by using interaction.plot(x1,x2,y) where x1 and x2 are the two independent variables, and y is the dependent variable.
  • 我尝试将绘图存储为变量并使用 grid.arrange,但它们无法存储到变量中(仅在绘图区域生成绘图).

    I tried to store the plots as variables and use grid.arrange, but they cannot be stored into a variable (just produce the plot in the plot area).

    > int1 <- interaction.plot(data_pos_10$Day,data_pos_10$Drug,data_pos_10$Tumor.Volume, + xlab="Day",ylab="Tumor Volume",main="Interaction Plot Batch 10", + legend=F, + col=c("red","red","green","black","blue"), + lwd=2, + lty=c(1,2,3,4,5)) > int1 NULL

    推荐答案

    在绘制代码之前,运行 par(mcol=c(2,1)) 以垂直堆叠它们或 par(mcol=c(1,2)) 水平堆叠它们.

    Before you do your plotting code, run par(mcol=c(2,1)) to stack them vertically or par(mcol=c(1,2)) to stack them horizontally.

    更多推荐

    在 R 中组合图

    本文发布于:2023-07-18 14:23:19,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1145676.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:组合

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!