减少多个barplot R中条形的宽度
reduce width of bars in multiple barplot R
我需要减少以下多个条形图中的条形宽度:
我尝试按照这里 Change width of bars in barchart (R) 使用 space
选项,但似乎有多个条形图(即在我的例子中每个变量有 4 个条形图)函数 space
确实不工作。
这里有一些重现情节的假数据:
mat_example = matrix(rnorm(40), 4, 10)
barplot(mat_example[,c(1:10)], beside = TRUE)
感谢您的任何建议。
在help(barplot)
中有这样一段:
space: the amount of space (as a fraction of the average bar width)
left before each bar. May be given as a single number or one
number per bar. If ‘height’ is a matrix and ‘beside’ is
‘TRUE’, ‘space’ may be specified by two numbers, where the
first is the space between bars in the same group, and the
second the space between the groups. If not given
explicitly, it defaults to ‘c(0,1)’ if ‘height’ is a matrix
and ‘beside’ is ‘TRUE’, and to 0.2 otherwise.
所以在你的情况下这应该有效:
barplot(table, beside=TRUE, space=c(0, 2))
以你为例:
mat_example <- matrix(rnorm(40), 4, 10)
barplot(mat_example[,c(1:10)], beside=TRUE, space=c(0, 5))
我需要减少以下多个条形图中的条形宽度:
我尝试按照这里 Change width of bars in barchart (R) 使用 space
选项,但似乎有多个条形图(即在我的例子中每个变量有 4 个条形图)函数 space
确实不工作。
这里有一些重现情节的假数据:
mat_example = matrix(rnorm(40), 4, 10)
barplot(mat_example[,c(1:10)], beside = TRUE)
感谢您的任何建议。
在help(barplot)
中有这样一段:
space: the amount of space (as a fraction of the average bar width) left before each bar. May be given as a single number or one number per bar. If ‘height’ is a matrix and ‘beside’ is ‘TRUE’, ‘space’ may be specified by two numbers, where the first is the space between bars in the same group, and the second the space between the groups. If not given explicitly, it defaults to ‘c(0,1)’ if ‘height’ is a matrix and ‘beside’ is ‘TRUE’, and to 0.2 otherwise.
所以在你的情况下这应该有效:
barplot(table, beside=TRUE, space=c(0, 2))
以你为例:
mat_example <- matrix(rnorm(40), 4, 10)
barplot(mat_example[,c(1:10)], beside=TRUE, space=c(0, 5))