简体   繁体   English

将几个地块放入一个地块的空间中

[英]Put several plots into exactly the space of one plot

I have all the parameters fixed to describe one plot including oma , mar , mgp , ... I want to divide the very plot area into several separate, exactly equally sized smaller plot areas which share both x and y label. 我已经修复了所有参数以描述一个图,包括omamarmgp ,......我想将非常绘图区域分成几个独立的,大小相同的较小的绘图区域,它们共享x和y标签。 For example something like this: 例如这样的事情:

三个地块合二为一

I found solutions to combine plots but with seperate axes. 我找到了解决方案来组合情节,但有单独的轴。 Any starting point for the problem here? 这个问题的任何起点?

You can set the outer margins to be big enough to hold the axes and labels, then set the regular margins to 0. Use par(mfrow or layout to split the inner region into the panels that you want, then do the plots without the axes and labels and add the axes and labels into the outer margins: 您可以将外边距设置为足以容纳轴和标签,然后将常规边距设置为0.使用par(mfrowlayout将内部区域拆分为所需的面板,然后执行没有轴的图形和标签,并将轴和标签添加到外边距:

par( oma=c(5,4,4,1)+0.1, mar=c(0,0,0,0) )
layout( matrix( 1:3, nrow=1 ) )
for( i in levels(iris$Species) ) {
    with( iris[ iris$Species==i, ], {
        plot(Sepal.Width, Sepal.Length, ann=FALSE, xaxt='n', yaxt='n',
            ylim=range(iris$Sepal.Length))
        axis(1, outer=TRUE)
        mtext(side=3, i ) }
    )
}
axis(2, outer=TRUE)

But it is probably simpler using lattice or ggplot2. 但使用lattice或ggplot2可能更简单。

I'd suggest looking at using ggplot2 to see if there is a solution there that meets your needs. 我建议使用ggplot2查看是否有满足您需求的解决方案。 I find the plot you linked to be visually confusing. 我发现你联系的情节在视觉上令人困惑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM