在R中,我创建了一个图,在左边有一个单独的轴,以为图的y轴指定水平标签。但是,标签被截断。即,不显示完整名称,仅显示名称的最后9个字符。我使用R axis
命令创建轴,并使用labels = names
参数指定名称。 names
是长度不同的字符标签名称的向量。
plot(x = c(0,mx),y=c(1,n),yaxt = 'n', xlab = "Dollars - 100,000's", cex.axis = .65, typ = 'n', ylab = '', cex.lab = .8)
axis(side = 2, at = seq(1,n), labels = names, las = 2, cex.axis = .65)
这是情节的样子:Plot with truncated names
您可以通过将mar
参数传递给par
函数来修改绘图的边距:
mar.default <- c(5,4,4,2) + 0.1
par(mar = mar.default + c(0, 4, 0, 0))
plot(x = c(0,mx),y=c(1,n),yaxt = 'n', xlab = "Dollars - 100,000's", cex.axis = .65, typ = 'n', ylab = '', cex.lab = .8)
axis(side = 2, at = seq(1,n), labels = names, las = 2, cex.axis = .65)
没有您的数据集的可复制示例,我不能保证它会立即起作用,也许您必须自行调整它。
否则,您可以提供数据的可复制示例:How to make a great R reproducible example