2015-06-03 44 views
0

我有以下數據表:如何調整GGPLOT2線圖的標籤,以顯示組,並添加空間

gIN <- c("A_1","A_2","A_3","A_4","B_1","B_2","B_3","B_4","B_5","C_1","C_2","C_3") 
bc <- c(1219.79, 1486.84, 1255.80, 941.87, 588.19, 304.02, 279.71, 373.40, 179.89, 385.02, 218.76, 423.33) 
group <- c("A","A","A","A","B","B","B","B","B","C","C","C") 

ex <- data.frame("gIN" = gIN, "bc" = bc, "group" = group) 

我有兩個問題:

(A)我想(B)我想增加相鄰組之間的間隔,A,B和C太靠近了,所以我們可以使用這些標籤來讀取「組」的值,而不是「gIN」。這將使較大的圖難以在眼睛上。

該生產線是在這裏:

ggplot(data=ex, aes(x=gIN, y=bc, group=group)) + 
    geom_line() + 
    geom_point() + 
    theme(axis.text.x = element_text(angle = 90, hjust = 1)) 

產生以下情節:

enter image description here

回答

0

user4968354建議我看看小了,我想出了這個。幾乎我在找什麼:

ggplot(data=ex) + geom_line(aes(x=gIN, y=bc,group=group)) + geom_point(aes(x=gIN, y=bc)) + facet_grid(. ~group, scales="free") 

乾杯。

相關問題