本文介绍了在R中为barplot旋转x轴标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试图让x轴标签在没有运气的条形图上旋转45度。这是我的代码如下: pre $ barplot(((data1 [,1] - average)/ average)* 100, srt = 45, adj = 1, xpd = TRUE, names.arg = data1 [,2], col = c(#3CA0D0 ), main =北美度假村垂直下降比率的最佳提升时间, ylab =标准化差额, yaxt ='n', cex.names = 0.65, cex.lab = 0.65) 解决方案 这是一种骇人听闻的方式。我猜测有一个更简单的方法。但是您可以通过从 barplot 保存小节位置并上下调整一些小部分,从而抑制小节标签和标签的情节文本。下面是mtcars数据集的一个例子: x labs text(cex = 1,x = x-.25,y = -1.25,labs, xpd = TRUE,srt = 45) I am trying to get the x axis labels to be rotated 45 degrees on a barplot with no luck. This is the code I have below:barplot(((data1[,1] - average)/average) * 100, srt = 45, adj = 1, xpd = TRUE, names.arg = data1[,2], col = c("#3CA0D0"), main = "Best Lift Time to Vertical Drop Ratios of North American Resorts", ylab = "Normalized Difference", yaxt = 'n', cex.names = 0.65, cex.lab = 0.65) 解决方案 EDITED ANSWER PER DAVID'S RESPONSE:Here's a kind of hackish way. I'm guessing there's an easier way. But you could suppress the bar labels and the plot text of the labels by saving the bar positions from barplot and do a little tweaking up and down. Here's an example with the mtcars data set:x <- barplot(table(mtcars$cyl), xaxt="n")labs <- paste(names(table(mtcars$cyl)), "cylinders")text(cex=1, x=x-.25, y=-1.25, labs, xpd=TRUE, srt=45) 这篇关于在R中为barplot旋转x轴标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-17 21:12