在 R 中绘制多个图时更改图的大小 [英] Change the size of a plot when plotting multiple plots in R

查看:38
本文介绍了在 R 中绘制多个图时更改图的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当您使用 par(mfrow=c()) 函数绘制不同的图时,是否有一种方法可以在 R 中定义图的大小.

I want to know if there is a way to define the size of a plot in R, when you are plotting different plots using the par(mfrow=c()) function.

举个简单的例子:

par(mfrow = c(3,1))
plot(1:2)
plot(1:2)
plot(1:2)

所有地块的大小都相同.

All plots will have the same size.

例如,是否可以使第三个图的大小不同?例如,使它的大小是其他地块的一半?

Is it possible, for instance, to make the size of the third plot different? For example make it half the size of the other plots?

如果我使用这个:

par(mfrow = c(3,1))
plot(1:2)
plot(1:2)
plot(1:2, ylim =c(0,1))

ylim 轴发生变化,但图的大小没有变化.

The ylim axis changes but no the size of the plot.

谢谢.

推荐答案

Try layout例如

layout(matrix(c(1,1,2,3,4,4), nrow = 3, ncol = 2, byrow = TRUE))
plot(1,main=1)
plot(2,main=2)
plot(3,main=3)
plot(4,main=4)

layout(matrix(c(1,1,2,1,1,2,3,4,4), nrow = 3, ncol = 3, byrow = TRUE))
plot(1,main=1)
plot(2,main=2)
plot(3,main=3)
plot(4,main=4)

给你

你也可以使用 par(fig= )例如

par(mar=c(2,2,2,1))
par(fig=c(0,7,6,10)/10)
plot(1,main=1)
par(fig=c(7,10,6,10)/10)
par(new=T)
plot(2,main=2)
par(fig=c(0,7,0,6)/10)
par(new=T)
plot(3,main=3)
par(fig=c(7,10,0,6)/10)
par(new=T)
plot(4,main=4)

给你

但我认为布局更适合使用

but i think layout better for use

这篇关于在 R 中绘制多个图时更改图的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆