更改使用barplot()创建的图形的宽度

问题描述 投票:1回答:2

当我使用barplot时,如果名称太大,则看不到条形名称。例如:

barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Barplot",
        names.arg=c("This is bar 1...1", "This is bar 1...2",
                    "This is bar 1...3", "This is bar 1...4"), 
        xpd=TRUE, las=1, lwd=1, cex.names=0.5)

当我使用horiz=TRUE时,我看不到左侧的名称:

barplot(as.numeric(c(2, 4, 1, 6)), col = c("lightblue"), main="Barplot", 
        names.arg=c("This is \nbar 2...1", "This is bar 2...2",
                    "This is bar 2...3", "This is bar 2...4"), 
        xpd=TRUE, las=1, lwd=1, horiz=TRUE, space=1)

使用名称中的换行符(例如“ This is \ nbar 2 ... 1”)或使用cex.names=0.5减小文本大小可“解决”问题,但我希望添加空格以使名称适合。

是否有能力更改包括图形在内的整个图形的宽度?

r bar-chart sweave
2个回答
2
投票

[当为horiz=FALSE(默认值)时,一种选择是使用las=2绘制与x轴垂直的条形名称,并在底部边缘增加高度以容纳名称的长度。要在页边空白处增加空间,请使用par(mar=c(b, l, t, r)),其中bltr是数字,给出希望底部,左侧,顶部和底部的线宽/高的数量右边距分别为。


0
投票

当您Export时,您可以调整宽度和高度enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.