barplot
を作成しましたが、凡例に適切な色がなく、グリッドがバーの前にあるという問題があります。私は伝説の箱に右の列を置き、棒の後ろにグリッドを置いていきたいと思います。凡例に色を追加
また、私はちょうど彼らに私がRでこれらの機能を行うことができますどのように
を識別するために、各バーの下にチェックを入れたいですか?私が使用
Rスクリプト:
autos_data <- read.table("data.dat", header=T, sep="\t")
barplot(rep(NA,length(autos_data)),ylim=c(0,max(autos_data)),axes=FALSE)
barplot(t(as.matrix(autos_data)), main=NULL, ylab= "% of Cloud usage", xlab="Input data size (MB)", ylim=c(0,50), beside=TRUE, lwd=1:2, angle=c(45,135), density=seq(5,40,10), col=c("blue","red","black","darkgreen"))
grid(NA, 5, lwd=1,lty=5, col="gray") # grid only in y-direction
# Place the legend at the top-left corner with no frame
coords="top"
legend(coords, c("WestVirginia","Chicago I","Chicago II","California"), text.col=par("col"), cex=1.2, bty="n", xpd=TRUE, horiz=TRUE, inset=c(0,-.22), angle=c(35,135,45,135), density=seq(5,40,10),col=c("blue","red","black","darkgreen"))
編集:
dput(autos_data)
structure(list(WestVirginia = c(29L, 29L, 23L, 23L), ChicagoI = c(30L,
21L, 36L, 26L), ChicagoII = c(39L, 42L, 35L, 46L), California = c(2L,
8L, 6L, 5L)), .Names = c("WestVirginia", "ChicagoI", "ChicagoII",
"California"), class = "data.frame", row.names = c("1500", "3000",
"4500", "6000"))
データ:
West-Virginia ChicagoI ChicagoII California
1500 29 30 39 2
3000 29 21 42 8
4500 23 36 35 6
6000 23 26 46 5
することができます 'dput(autos_data)'私の答えよりも – rbm