gpt4 book ai didi

减少多个条形图 R 中条的宽度

转载 作者:行者123 更新时间:2023-12-04 10:44:47 24 4
gpt4 key购买 nike

我需要减少下面多个条形图中条形的宽度:

enter image description here

我尝试使用 space选项按照这里 Change width of bars in barchart (R)但似乎有多个条形图(即在我的情况下每个变量有 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))

enter image description here

关于减少多个条形图 R 中条的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50188638/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com