Skip to content
Prev 206342 / 398503 Next

Barchart bar lengths not proportionate

I think you should rather look at the origin= parameter in barchart. See

?panel.barchart for a discussion of this exact problem:
"  origin: the origin for the bars.  For grouped displays with 'stack
=
          TRUE', this argument is ignored and the origin set to 0. 
          Otherwise, defaults to 'NULL', in which case bars start at
          the left (or bottom) end of a panel.  This choice is
somewhat
          unfortuntate, as it can be misleading, but is the default
for
          historical reasons.  For tabular (or similar) data, 'origin
=
          0' is usually more appropriate; if not, one should
reconsider
          the use of a bar chart in the first place (dot plots are
          often a good alternative). "

The result of setting origin is more sensible:
require(lattice)
da <- expand.grid(A=c("a","b"), x=1:4)
da$y <- c(1,5,6,3,2,0,6,0)

barchart(y~x|A, data=da, horizontal=FALSE)

barchart(y~x|A, data=da, horizontal=FALSE, origin=0)
Rex,

I think this problem can be solved using xlim()/ylim() argument. Look
at the
follwing code:

require(lattice)
da <- expand.grid(A=c("a","b"), x=1:4)
da$y <- c(1,5,6,3,2,0,6,0)

barchart(y~x|A, data=da, horizontal=FALSE)

barchart(y~x|A, data=da, horizontal=FALSE,
         ylim=c(0, 1.05*max(da$y)))

At your disposal.
Walmes.
Rex C. Eastbourne wrote:
whose
bars
represent
are not
-----
..oooO
..................................................................................................
..(....)... 0ooo...                              Walmes Zeviani
...\..(.....(.....)...     Master in Statistics and Agricultural
Experimentation
....\_)..... )../....       walmeszeviani at hotmail.com, Lavras - MG,
Brasil
............
(_/............................................................................................