Peng Cai wrote:
Hi Peter,
I'm not sure but it seems "scales" command works only with integer values.
If the y-axis values are very small (such as -0.03, -0.02, -0.01, 0,
0.01,..., 0.08). My current plot has values 0, 0.05, and 0.10 only. But I
need it to extend it to negative numbers and reduce the scale width (like
-0.04, -0.02, 0, 0.02,...).
Can I change these too? Thanks!
Use, e.g.
myYscale <- seq(-0.04, 0.08, 0.02)
barchart(...,
...,
scales = list(y = list(at = myYscale)),
...
)
-Peter Ehlers
Peng
On Thu, Nov 26, 2009 at 3:18 PM, Peter Ehlers <ehl...@ucalgary.ca> wrote:
Peng Cai wrote:
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).
replace the line
col = 2:4,
with
par.settings = simpleTheme(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,...
add the line
scales = list(y = list(at = -2:8)),
or whatever tick locations you prefer.
-Peter Ehlers
Any help would be greatly appreciated,
Thanks,
Peng
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org 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.
______________________________________________
R-help@r-project.org 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.