2017-11-22 15 views
0

私は負の値を持つ2つのデータセットを持っているので、barplotは私に棒グラフのプロットを与えます。棒を得るために、y軸の原点を負の値に設定するには?私が持っているものバープロットの原点を変更するにはどうすればいいですか?

私が欲しいもの
A <- c(-7.3, -2.17, 1.05) 
B <- c(-3.69, -5.04, -0.746) 
AB <- c(A, B) 

barplot(AB, col = c("darkgray","darkgray","darkgray","lightgray","lightgray","lightgray"),# 
    names.arg=c("A1", "A2", "A3", "B1", "B2", "B3")) 
legend("bottomright", legend = c("A", "B"), fill = c("darkgray", "lightgray"), horiz = T) 

enter image description here

enter image description here

答えて

1
new <- abs(-8 - AB) 

barplot(new, beside=TRUE, ylim=c(0, 12), yaxt="n", 
    col = c("darkgray","darkgray","darkgray","lightgray","lightgray","lightgray"),# 
    names.arg=c("A1", "A2", "A3", "B1", "B2", "B3")) 

axis(2, seq(0, 12, 2), labels=seq(-8,4,2)) 
box(bty="l") 
legend("topright", legend = c("A", "B"), fill = c("darkgray", "lightgray"), horiz = T) 

enter image description here

関連する問題