当nrow = 1时,改变grid.arrange产生的行的高度 [英] altering height of rows produced by grid.arrange when nrow=1

查看:299
本文介绍了当nrow = 1时,改变grid.arrange产生的行的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

道歉,如果这个问题已经被回答,但我似乎无法找到我所需要的。



我已经在ggplot2中生成了两张图, grid使用grid.arrange如下:

  grid.arrange(p1,p2,main =Title,ncol = 2) 

这给我这样的情节:





(对不起,我不明白如何让这个在帖子中显示我的图片,如果有人可以帮助我,那就太好了!我不想用链接来惹恼别人。)



如何更改此代码以使图形仍然并排排列,但它们不会延长整个对象的长度?我想他们是方形的。



我知道我可以添加一个参数高度,但不确定这是我需要的还是什么都没有看到在这里申请它。

也可以使用 heights widths 参数指定相对高度和宽度,如下所示:

  grid.arrange(p1,p2,widths = unit(0.5,npc),heights = unit(0.5,npc), main =Title,ncol = 2)


Apologies if this question has already been answered but I cant seem to find what I need.

I have produced two plots in ggplot2 which I am combining into the same grid using grid.arrange as follows:

grid.arrange(p1,p2,main="Title", ncol=2)

which gives me the plots side by side like so:

(Sorry I don't understand how to get this to show my image within the post, if you anyone could help me with that as an aside that would be great! I don't want to annoy people by using links.)

How can I alter this code so that the graphs are still side by side but they are not elongated the entire length of the object? I would like them to be square.

I know that I can add an argument "heights" but not sure if this is what I need and haven't seen anything on here applying it in this situation.

Thanks!

解决方案

You can also specify relative heights and widths using the heights and widths arguments to grid.arrange like so:

grid.arrange(p1 , p2 , widths = unit(0.5, "npc") , heights=unit(0.5, "npc") , main="Title", ncol=2)

这篇关于当nrow = 1时,改变grid.arrange产生的行的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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