2015-02-09 124 views
1

我正在繪製r的barplot。R中barplot的X軸上的名稱?

我的數據:

,Up,Down 
Floor-1,690,1511 
Maxim,1354,2515 
Hosiptal,1358,2649 
Bank,459,589 
Air-port,1359,2097 
Bus-stand,1234,1928 
Taxi-Stand,213,138 
Railway-station,557,610 

腳本的barplot是: Link to image

因爲我沒有足夠的聲譽;我不能發佈圖片... :)

我的腳本是:

d <- read.csv("file.csv") 
    barplot(t(as.matrix(d[, 2:3])),beside=TRUE,legend = c("Up","Down"), ylab = "Number of steps", 
    xlab = "Building", main = "Up and Down steps",names.arg= as.matrix(d$X) ,col=rainbow(2),type="h") 

在該圖中的x軸「總線立場」的標貼和和「鐵路站」缺失。

如何標記這些缺失的標籤?

回答

3

你可以嘗試使標籤與cex.names

x<- c(10, 20, 30, 40, 50) 

names <- c("Name", "Long name", "This name is long", "Name", "Name") 

barplot(x, names.arg=names) 
# Names might not all fit, depending on size of graph 
barplot(x, names.arg=names, cex.names=.5) 
# All names will probably fit 
+0

是變小。它在更改爲cex.names = .5後運行。 – Issac 2015-02-09 18:59:42