gpt4 book ai didi

r - 如何使X轴上的字体大小变量变小

转载 作者:行者123 更新时间:2023-12-01 02:41:37 26 4
gpt4 key购买 nike

我有这段代码可以创建条形图,但是我想将x轴上的名称更改为物种名称,并且我想使字体更小以便可以全部使用。我尝试使用cex功能有各种组合,但没有用。我会很感激这个建议吗?

    count <-     
matrix(c(16,102,11,106,15,95,26,87,18,99,21,103,12,110,30,103,10,107,20,87,13,110,17,93), nrow = 2)


barplot(count, beside=T, legend =T, ylim=c(0,130),
col=c("darkolivegreen3", "firebrick1"),
ylab="Frequency (no. of moths)", las = 3,
names = c("tiger\nCo", "tiger\nCr" , "eyes\nCo", "eyes\nCr", "mottled\nCo","mottled\nCr", "pepperL\nCo","pepperL\nCr", "pepperD\nCo","pepperD\nCr", "convol\nCo", "convol\nCr"))


legend(6,130, legend=(c("survived","predated")), pch=c(15,22), cex=0.8, col=c("darkolivegreen3","firebrick1"))

最佳答案

好吧,根据?barplot页面,有一个cex.names参数:

barplot(count, beside=T, legend =T, ylim=c(0,130),
col=c("darkolivegreen3", "firebrick1"),
ylab="Frequency (no. of moths)", las = 3,
cex.names=0.8,
names.arg = c("tiger\nCo", "tiger\nCr" , "eyes\nCo", "eyes\nCr",
"mottled\nCo","mottled\nCr", "pepperL\nCo",
"pepperL\nCr", "pepperD\nCo","pepperD\nCr",
"convol\nCo", "convol\nCr"))
legend(6,130, legend=(c("survived","predated")), pch=c(15,22),
col=c("darkolivegreen3","firebrick1"))


我承认找到正确的cex。*参数有时很困难,有时需要单独调用axis,但是在这里看来微不足道。

关于r - 如何使X轴上的字体大小变量变小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27367231/

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