gpt4 book ai didi

r - par(mfrow=c(1,2)) 不显示并排密度图

转载 作者:行者123 更新时间:2023-12-04 11:29:40 32 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Lattice: multiple plots in one window?

(3 个回答)


5年前关闭。



par(mfrow=c(1,2))
plot(1:12, log = "y")
plot(1:2, xaxs = "i")

enter image description here

但是,当我尝试进行并排密度图时,这些图会单独输出:
# load the stud.recs dataset
library(UsingR)

par(mfrow=c(1,2))
densityplot(stud.recs$sat.v)
densityplot(stud.recs$sat.m)

为什么是 par(mfrow=c(1,2))不适用于密度图?

最佳答案

densityplot生成点阵图(与基本图不同)。

因此,为了让它们并排,您需要执行以下操作:

library(UsingR)
par(mfrow=c(1,2))
a <- densityplot(stud.recs$sat.v)
b <- densityplot(stud.recs$sat.m)

#this is the print.lattice method below
# ?print.trellis for help
print(a, position = c(0, 0, 0.5, 1), more = TRUE)
print(b, position = c(0.5, 0, 1, 1))

enter image description here

关于r - par(mfrow=c(1,2)) 不显示并排密度图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31099259/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com