Hello, I do this a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2) b=matrix(a,nrow=4) rownames(b)=c("20/04/2002","21/04/2002","22/04/2002","23/04/2002") colnames(b)=c("p1","p2","p3") barplot(b,beside=T,col=(c("red","orange","yellow"))) then I have http://www.mif.vu.lt/~roka5178/barplot1.JPG<http://www.mif.vu.lt/%7Eroka5178/barplot1.JPG> but I need to have http://www.mif.vu.lt/~roka5178/barplot.JPG<http://www.mif.vu.lt/%7Eroka5178/barplot.JPG> how can i do this? i need to to change axis x whit y -- Robertas [[alternative HTML version deleted]]
You need the transpose of the matrix (or create it differently in the first place!). Changing the last line to> barplot(t(b),beside=T,col=(c("red","orange","yellow")))should do the trick. On 29/11/06, Robertas Kavali?nas <robertas.kavaliunas at gmail.com> wrote:> Hello, > I do this > a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2) > b=matrix(a,nrow=4) > rownames(b)=c("20/04/2002","21/04/2002","22/04/2002","23/04/2002") > colnames(b)=c("p1","p2","p3") > barplot(b,beside=T,col=(c("red","orange","yellow"))) > > then I have http://www.mif.vu.lt/~roka5178/barplot1.JPG<http://www.mif.vu.lt/%7Eroka5178/barplot1.JPG> > but I need to have > http://www.mif.vu.lt/~roka5178/barplot.JPG<http://www.mif.vu.lt/%7Eroka5178/barplot.JPG> > how can i do this? > i need to to change axis x whit y > > -- > Robertas > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP
--- Robertas Kavali?nas <robertas.kavaliunas at gmail.com> wrote:> Hello, > I do this >a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2)> b=matrix(a,nrow=4) >rownames(b)=c("20/04/2002","21/04/2002","22/04/2002","23/04/2002")> colnames(b)=c("p1","p2","p3") > barplot(b,beside=T,col=(c("red","orange","yellow"))) > > then I have >http://www.mif.vu.lt/~roka5178/barplot1.JPG<http://www.mif.vu.lt/%7Eroka5178/barplot1.JPG>> but I need to have >http://www.mif.vu.lt/~roka5178/barplot.JPG<http://www.mif.vu.lt/%7Eroka5178/barplot.JPG>> how can i do this? > i need to to change axis x whit y> RobertasThis is dirty code but it works. Just transpose the matrix before you plot it. a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2) b= matrix(a,nrow=4) rownames(b)=c("20/04/2002","21/04/2002","22/04/2002","23/04/2002") colnames(b)=c("p1","p2","p3") b1 <- t(b)# Transpose of 'b' barplot(b1,beside=T,col=(c("red","orange","yellow")))