# [R] problems with lattice barchart

Juan Santos juan.santos at vi.ieo.es
Tue Dec 14 14:20:44 CET 2010

```   Hello everybody!
IÂ´m trying to create figures summarizing the abundance of a given species
(y), by its length classes (x), year (conditional factor) and a grouping
named as "fraction". I am using the latticeÂ´s barchart but some problems
arises:
When  I run the function, the sizes become characters, and this is the
starting problem for me when trying to adjust the x-axis in order to achieve
a  good-looking. In  particular,  I  have  found  that  when  range of
length-classes is high, the output  yield a matted looking in the x-axis,
which in some cases is unreadable. In order to achieve a wider space between
x-axis annotations, I was trying to reduce the number of sizes shown in the
figure,  but so far I got a few improvements in the final results. Here you
will find a piece of the data frame,
> x[1:25,]
Length.class year   fraction     y
1             6 2006 Fraction.a     0
2             7 2006 Fraction.a     0
3             8 2006 Fraction.a   191
4             9 2006 Fraction.a   784
5            10 2006 Fraction.a    38
6            11 2006 Fraction.a  1135
7            12 2006 Fraction.a  1810
8            13 2006 Fraction.a  2836
9            14 2006 Fraction.a  6625
10           15 2006 Fraction.a  6414
11           16 2006 Fraction.a 10554
12           17 2006 Fraction.a 12423
13           18 2006 Fraction.a 15260
14           19 2006 Fraction.a 11126
15           20 2006 Fraction.a  9830
16           21 2006 Fraction.a  8460
17           22 2006 Fraction.a  6062
18           23 2006 Fraction.a  4382
19           24 2006 Fraction.a  3555
20           25 2006 Fraction.a  1792
21           26 2006 Fraction.a  2220
22           27 2006 Fraction.a  1235
23           28 2006 Fraction.a   465
24           29 2006 Fraction.a     0
25           30 2006 Fraction.a    59
and this is the  barchart specifications,
plot.i<-barchart(x[,4]~x[,1]|x[,2],horizontal=F,stack=TRUE,layout=paneis,
par.settings = simpleTheme(col = c("red3","olivedrab")),groups=x[,3],
strip = strip.custom (bg = c('transparent'),par.strip.text = list(cex =
0.8)),auto.key=list(columns=2),
panel=function(...,box.width,border){
panel.grid(h=-1,v=0)
panel.abline(v=TML,col="red",lty=2)
panel.barchart(...,box.width = .99,border="black")},
,xlab="Length Size",ylab="Y")
Can someone guide me to solve the problem?

--
```