[R] lattice barchart with "negative" bars

Deepayan Sarkar deepayan at stat.wisc.edu
Tue Dec 10 15:30:08 CET 2002


On Tuesday 10 December 2002 06:11 am, Luis Torgo wrote:
> Dear all,
>
> I'm trying to use the lattice barchart function to obtain a bar plot of a
> variable for different values of two factors. The thing I'm trying to do is
>
> something like this:
> > barchart(MyVar ~ season | place, data=mydataset)
>
> My problem is that the column MyVar has some negative values and I would
> like them to be represented as bars stacking down from zero instead of what
> the function does that is finding the minimum value and then stacking all
> bars from this minimum value up. I've looked into the the help pages and I
> saw no way to go around this behaviour. Is there an easy way to get these
> "negative" bars?

No, I don't think so (short of using a modified panel.barchart, which should 
be relatively easy -- panel.barchart essentially has just 3 lines of code). 
But this seems very reasonable thing to want, so I'll add an option for this.

You could also use xyplot with type = "h", but that will give you lines 
instead of bars.

Deepayan




More information about the R-help mailing list