本文介绍了R绘制所有轴标签(防止被跳过)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I manually add the following labels with (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? (另外,为了获得额外的荣誉,我如何将整个图像向下移动几个像素?)

How do I force all labels to be drawn so 1,3,5,6, and 11 are not skipped? (also, for extra credit, how do I shift the whole thing down a few pixels?)

推荐答案

?axis告诉您:

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

Play with cex.axis so that labels are small enough to fit without overlapping

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)

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

If you widen you graph (manually by dragging or programmatically), you can increase the size of your labels.

这篇关于R绘制所有轴标签(防止被跳过)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:57
查看更多