gpt4 book ai didi

r - R绘制所有轴标签(防止被跳过)

转载 作者:行者123 更新时间:2023-12-03 21:05:08 26 4
gpt4 key购买 nike

当我使用(axis(1, at=1:27, labels=labs[0:27]))手动添加以下标签时:

> labs[0:27]
[1] "0\n9.3%" "1\n7.6%" "2\n5.6%" "3\n5.1%" "4\n5.7%" "5\n6.5%" "6\n7.3%" "7\n7.6%" "8\n7.5%" "9\n7%" "10\n6.2%" "11\n5.2%"
[13] "12\n4.2%" ........


我得到以下内容:



如何强制绘制所有标签,以便不跳过1,3,5,6和11? (同样,为了获得额外的荣誉,我如何将整个图像向下移动几个像素?)

最佳答案

?axis告诉您:


该代码尽力不绘制重叠的刻度标签,因此将省略标签邻接或重叠先前绘制的标签的位置。例如,这可能导致每隔一个刻度被标记。 (刻度线是从左到右或从下到上绘制的,标签之间至少要留一个“ m”的大小。)


播放cex.axis,以使标签小到足以容纳而不会重叠

labs <-c("0\n9.3%","1\n7.6%","2\n5.6%","3\n5.1%","4\n5.7%","5\n6.5%","6\n7.3%",
"7\n7.6%","8\n7.5%","9\n7%", "10\n6.2%","11\n5.2%","12\n4.2%",12:27)
plot(1:27,xaxt = "n")
axis(side=1, at=1:27, labels=labs[0:27],cex.axis=0.35)


如果您加宽图形(手动通过拖动或以编程方式),则可以增加标签的大小。

关于r - R绘制所有轴标签(防止被跳过),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8688854/

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