Dear Deepayan and other users,

thanks a lot, that was exactly what i intended to get. However, there are 
some aspects of the plot that can be improved. 
It would be nice to have the same wisth of the bars in all panels. I saw 
the bow.width-argument, but as I understood it is no help to get a fixed 
absolute width of bars in all panels. Is there a solution?

Secondly I would like to get horizontal grid lines at the positions of the 
y-axis tick marks(from -2 to 6, increment |2|). I tried the following:


PLOT<-barchart(data=df,Ratio~reorder(Compound,as.numeric(Class))|Class,origin=0,scales=list(x=list(relation="free"),
y=list(tck=1)))

But this does not work. When using: 

P<-barchart(data=df, Ratio~reorder(Compound,as.numeric(Class))|Class, 
origin=0,
scales=list(x="free",y=list(alternating=3)),ylab="log2 ratio 
(winter/summer)",
panel=function(...){panel.barchart(...);

grid.grill(v=unit(c(-2,-1,0,1,2,3,4,5,6),"native"),default.units="native")})

i get horizontal lines, but not in correspondence with the y-scaling and 
get some
vertical lines as well. Where is my mistake? Am i refering to the wrong 
coordinate system (tried with npc, but also did not work)?

Thanks a lot for your help,

Henning




>             
> -------- Original-Nachricht --------
> Datum: Wed, 16 Jul 2008 09:48:35 -0700
> Von: "Deepayan Sarkar" <deepayan.sarkar@gmail.com>
> An: "Henning Wildhagen" <HWildhagen@gmx.de>
> CC: r-help@r-project.org
> Betreff: Re: [R] barchart with bars attached to y=0-line
> 
>             On 7/16/08, Henning Wildhagen <HWildhagen@gmx.de> wrote:
> > Dear R users,
> >
> >  i am using the following code to produce barcharts with lattice:
> >
> >  Compound<-c("Glutamine", "Arginine", "Glutamate", "Glycine", "Serine",
> >  "Glucose", "Fructose", "Raffinose",
> >  "Glycerol", "Galacglycerol", "Threitol", "Galactinol", "Galactitol")
> >
> >
> >  
> Class<-c("aminos","aminos","aminos","aminos","aminos","sugars","sugars","sugars","glycerols","glycerols","sugar
> >  alcohols","sugar alcohols","sugar alcohols")
> >
> >  set.seed(5)
> >  Ratio<-rnorm(13, 0.5, 3)
> >
> >  df<-data.frame(Compound, Class,Ratio)
> >
> >  library(lattice)
> >
> >  P<-barchart(data=df,Ratio~Compound|Class)
> >
> >  However, I would like to have the bars attached to an imaginary 
> y=0-line so
> >  that they go up if Ratio>0 and down if Ratio<0.
> >  I saw some older entries in the mailing list supposing to use
> >  panel.barchart. However, I did not fully understand the usage of this
> >  function. Also, it was annouced to add an option to "barchart" to make 
> it
> >  easier to get this type of plot.
> >
> >  Has anyone an idea what the easiest solution might be?
> 
> barchart(data=df,Ratio~Compound|Class, origin = 0)
> 
> >  A second problem is concerning the display of the "Compound"-objects 
> in
> >  accordance with the conditioning variable "Class". In other words: Is 
> it
> >  possible to use the whole space of each panel for only those
> >  "Compound"-objects which belong to the "Class" displayed in that 
> particular
> >  panel? Of course, for this purpose the panels have to be "detached" to
> >  allow appropiate labling of the x-axis.
> 
> barchart(data=df,Ratio~Compound|Class, origin = 0,
>          scales = list(x = "free"))
> 
> But this would work better if the levels of Compound are adjacent
> within Class; e.g.
> 
> barchart(data=df,Ratio~reorder(Compound, as.numeric(Class))|Class,
>           origin = 0, scales = list(x = "free"))
> 
> -Deepayan
> 
        
-- 



	[[alternative HTML version deleted]]

