Skip to content

barchart() {Lattice} help.

18 messages · Peng Cai, David Winsemius, Peter Ehlers +1 more

#
Peng Cai wrote:
replace the line

  col = 2:4,

with

  par.settings = simpleTheme(col = 2:4),
add the line

  scales = list(y = list(at = -2:8)),

or whatever tick locations you prefer.

  -Peter Ehlers
#
Peng Cai wrote:
Use, e.g.

  myYscale <- seq(-0.04, 0.08, 0.02)
  barchart(...,
    ...,
    scales = list(y = list(at = myYscale)),
    ...
  )

  -Peter Ehlers
#
On Nov 26, 2009, at 6:12 PM, Peng Cai wrote:

            
?panel.abline
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
Peng Cai wrote:
Here's some code related to the data you posted earlier.

barchart(data.matrix(dta), horizontal = FALSE, stack = TRUE,
              par.settings = simpleTheme(col = 2:4),
              panel=function(x,y,...){
                panel.abline(h=c(-2,0,3,4), col.line="gray")
                panel.barchart(x,y,...)
              },
              scales = list(y = list(at = -2:8)),
              auto.key = list(space = 'right', rectangles=TRUE,
                  points=FALSE)
)

If you want the gray lines in front of the bars, switch the
order of the panel functions. With lattice, it's all about
what goes into each panel (you have only one panel here).
If you want more than one thing in a panel, you have to set
up a function to do those things.

I had to add the rectangles= and points= arguments to
auto.key to get the same key as you had earlier.

  -Peter Ehlers
#
Cannot reproduce. Seems to work as documented. Maybe your code  
(whatever it might be)  is not correct?
#
Peng,

Did you try the code I sent? If not, why not?
If you want equally spaced grid lines, use panel.grid() in
place of panel.abline().

BTW, I don't understand what that "title=..." stuff in
your auto.key() call is supposed to do. I think it just
results in title=NULL.

  -Peter Ehlers
Peng Cai wrote:
#
As I wrote earlier:

"I had to add the rectangles= and points= arguments to

 auto.key to get the same key as you had earlier."

and the relevant line in the code was:

  auto.key = list(space = 'right', rectangles=TRUE, points=FALSE)

 -Peter Ehlers
Peng Cai wrote:
#
On Fri, Nov 27, 2009 at 9:21 AM, Peng Cai <pengcaimaillist at gmail.com> wrote:
Read ?barchart, specifically the entry for 'scales'. Hint: figure out
what the line

     scales = list(y = list(at = myYscale)),

does.

-Deepayan