2014-09-02 138 views

回答

1

我認爲這是你在找什麼:

# Category names 
my.names <- c("test1","test2","test3") 

# Example data 
data <- runif(length(my.names)) 

# Normalize the example data as a percentage of the total 
data.norm <- data/sum(data) 

# Use barplot to plot the results, plot without an x axis 
x <- barplot(data.norm,names.arg=my.names,xaxt="n") 

# Apply new x labels rotated by 45 degrees 
text(cex=1, x=x-0.1, y=-0.05, my.names, xpd=TRUE, srt=45) 
+0

可以請你告訴我如何修改代碼以獲得45度旋轉的X軸標籤?問候 – user1997567 2014-09-02 18:25:42

+0

我編輯我的迴應上面,包括旋轉45度的標籤。希望能幫助到你。 – 2014-09-03 22:01:57

0

這是我做的:

bp<-barplot(data.norm, beside=TRUE, col=c("grey10","grey20","grey30","grey40","grey50","grey60","grey70","grey80","grey90","grey80","grey70","grey60",))text(bp, par("usr")[3], labels=my.names, srt=45, pos=2, xpd=TRUE,offset=0.01) 

它的工作的罰款我希望這對其他人有幫助 Regards

相關問題