【发布时间】:2020-01-22 16:12:11
【问题描述】:
我现在已经尝试了很多东西,但它似乎对我不起作用。我正在寻找一种解决方案来转动我的 x 轴标签(到 45°)并解耦轴的标题,这样标签就不会覆盖我的轴标题。这是我的代码
barplot(regions$no_rows,xlab="regions",ylab="number of occurences",
main="XXX",
names.arg = regions$ID, las=2,cex.lab=1,cex.names= 0.65)
我已经裁剪了边距并缩小了标签的字体,但没有一种解决方案可以简单地显示图表,然后将轴标题与标签分开。 有了这个解决方案,我也没有得到 45° 的倾角。我也为此尝试了几个代码,例如这个:
regions = regions[with(regions, order(-no_rows)), ]
end_point = 0.5 + nrow(regions) + nrow(regions)-1
barplot(regions$no_rows, col="grey50",
main="XXX",
ylab="occurences", ylim=c(0,5+max(regions$no_rows)),
xlab = "regions",
space=1)
text(seq(-0.5,end_point,by=2), par("usr")[3],
srt = 45, adj= 1, xpd = TRUE,
labels = paste(regions$ID), cex=0.65)
也不好看,因为 x 轴标题太靠近标签,而且标签也太靠近条形:
非常感谢您的帮助! P.s.:可以说这是我得到的df
regions
ID no_rows
A 100
B 8
C 50
......
【问题讨论】: