Hi R Users,

I'm trying to plot a stacked barplot. Here is data:

Sample Col1 Col2 Col3
Row1 -2 4 -1
Row2 3 -2 4
Row3 3 5 -2
Row4 4 1 -1

I'm using following R code:

library(lattice)
dta<-read.table("data.txt", header=TRUE, row.names="Sample")
barchart(data.matrix(dta),
        horizontal=FALSE,
        stack=TRUE,
col=2:4,
        auto.key=list(space="right",
title=names(dimnames(dta))[2])
)

Above code is working fine, but I need help with:

1) Legend boxes have default colors, whereas I'm looking them to match with
barplot colors (col=2:4).
2) Can I increase scale for y axis, like currently it plotting -2,0,2,4,...
I would like it as -2,-1,0,1,...

Any help would be greatly appreciated,

Thanks,
Peng

	[[alternative HTML version deleted]]


