<<目次へ


いろいろな棒グラフ


freq<-c(70,30)
names(freq)<-c("好き","嫌い")
barplot(freq,col="blue",xlab="好き嫌い",ylab="度数")
abline(h=0)



x<-matrix(c(25,15,10,30),2,2,byrow=T)
d.names.c<-paste(c("モデルあり","モデルなし"))
color <- c("red", "blue")
barplot(x,beside=T,names.arg=d.names.c,col=color)
legend(2.5,30,paste(c("与える","与えない")),1:ncol(x),fill=color)
abline(h=0)



data<-matrix(c(62,8,30,6,82,12,28,48,24),ncol=3)
d.names.c<-paste(c("ガラガラ","人形","トラック"))
d.names.r<-paste(c("ブルーの服","ピンクの服","白の服"))
dm <- matrix(c(62,8,30,6,82,12,28,48,24),ncol=3)
d.seg.xs <- rep((0.2 + 1) * 1:(ncol(dm) - 1), each=nrow(dm))
d.seg.xe <- rep((0.2 + 1) * 2:ncol(dm) - 1, each=nrow(dm))
d.seg.ys <- apply(dm[,1:(ncol(dm) - 1)], 2, cumsum)
d.seg.ye <- apply(dm[,2:ncol(dm)], 2, cumsum)
barplot(dm,ylim=c(0,100),names.arg=d.names.c,legend.text=d.names.r)
segments(d.seg.xs, d.seg.ys, d.seg.xe, d.seg.ye)