r - 如何将 4 对图组合在一个图中?

标签 r plot

如果我用琐碎的问题打扰您,我很抱歉。

我应该制作 1 个图形,其中包含 4 个不同的相关成对图。
通缉图的外观如下:
enter image description here

我用函数pairs()制作的每一个成对图:

pairs(cbind(AAPL,MSFT,INTC,FB,MU,IBM),main="Frequency=1 Min.",font.labels = 2, col="blue",pch=16, cex=0.8, cex.axis=1.5,las=1)
pairs(cbind(AAPL,MSFT,INTC,FB,MU,IBM),main="Frequency = 2 Min.",font.labels = 2, col="blue",pch=16, cex=0.8, cex.axis=1.5,las=1)
pairs(cbind(AAPL,MSFT,INTC,FB,MU,IBM),main="Frequency = 5 Min.",font.labels = 2, col="blue",pch=16, cex=0.8, cex.axis=1.5,las=1)
pairs(cbind(AAPL,MSFT,INTC,FB,MU,IBM),main="Frequency = 10 Min.",font.labels = 2, col="blue",pch=16, cex=0.8, cex.axis=1.5,las=1)

当我通过使用布局函数组合上述成对图时,它不起作用(据我从类似问题中理解 layout() 和pairs() 不能组合)。

如果有人有一种优雅的方式来组合 4 个不同的相关成对图,我们将不胜感激。

最佳答案

更新,12014-07-31 11:48:35Z

ilir pointed out below pairs不知何故覆盖par ,很可能是出于某种充分的理由。

@ user44037,你能解决这个代码片段的问题吗?复制/粘贴自 here .我相信可以使用 splom 找到解决方案来自 lattice .看看?splom .

 library(lattice) 
 splom(~iris[1:3]|Species, data = iris, 
      layout=c(2,2), pscales = 0,
      varnames = c("Sepal\nLength", "Sepal\nWidth", "Petal\nLength"),
      page = function(...) {
          ltext(x = seq(.6, .8, len = 4), 
                y = seq(.9, .6, len = 4), 
                lab = c("@user44037,", "can you solve your", "problem working form ", "this code snippet?"),
                cex = 1)
      })

enter image description here

初步答复,12014-07-31 11:35:33Z

只需关注 Avinash directions通过复制/粘贴来自 the website Quick-R 的代码.随意改进这个例子。

如果您提供可重现的示例,我很乐意解决您的具体问题。
# 4 figures arranged in 2 rows and 2 columns
attach(mtcars)
par(mfrow=c(2,2))
plot(wt,mpg, main="Scatterplot of wt vs. mpg")
plot(wt,disp, main="Scatterplot of wt vs disp")
hist(wt, main="Histogram of wt")
boxplot(wt, main="Boxplot of wt")

enter image description here

关于r - 如何将 4 对图组合在一个图中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25056597/

相关文章:

r - expss表中的百分比不准确

string - 阻止 R 将尾随空格写入保存的字符串

r - 我必须将收集与磁盘框架一起使用吗?

python - 使用 Bokeh 中 x 坐标的数据帧索引绘制 Pandas 数据帧

python - matplotlib 中的刻度线

r - 将唯一值提取到 R 中的文件中

r - 根据其中一列中的值将行添加到数据框中

r - 'x' 是一个列表,但没有组件 'x' 和 'y'

matlab - 如何在 MATLAB 中绘制特定多边形区域之外的点

matlab - 在 Matlab 中向 3D 绘图数据点添加字母