【问题标题】:par(mfrow=c(1,2)) not displaying side-by-side densityplots [duplicate]par(mfrow = c(1,2))不显示并排的密度图[重复]
【发布时间】:2015-06-28 21:10:39
【问题描述】:
par(mfrow=c(1,2))
plot(1:12, log = "y")
plot(1:2, xaxs = "i")

但是,当我尝试做一个并排的密度图时,这些图会分别得到输出:

# 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 没有记录在 UsingR 中,但确实存在。还有DensityPlot,但它使用基本图形。 densityplot 也不在命名空间中,所以我不确定它是如何暴露的。当然,将问题与这个问题分开。
  • 好的。明白了,正如他们所说的红鲱鱼。 UsingR 与这个问题无关。 densityplot 属于 lattice
  • 赞成你的第一条评论,因为它把我指向了 DensityPlot,这正如我所期望的那样工作 densityplot 工作

标签: r


【解决方案1】:

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))

【讨论】:

  • 这个建议的解决方案对我不起作用。
猜你喜欢
  • 2022-11-21
  • 1970-01-01
  • 2019-05-31
  • 1970-01-01
  • 2011-11-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-19
相关资源
最近更新 更多