On 2010-02-20 6:22, Walmes Marques Zeviani wrote:

Hi all,

I am using barchart() to plot values above the bars. When using groups argument 
we get bars grouped arround a given x level. By placing values above this bars 
we need to know the respective x coordinates. How can I get it?

require(lattice)
da<- expand.grid(x=1:5, z=1:3, w=1:2)
da$y<- rpois(da$x, lambda=23)

barchart(y~x|w, groups=z, data=da, horizontal=FALSE,
          panel=function(x, y, subscripts, groups, ...){
            panel.barchart(x, y, subscripts=subscripts, groups=groups, ...)
            d<- 0.22 #<------ how obtain "d" or coordinates?
            panel.text(x+c(-d,0,d), y, label=y, pos=3)
          })


The width of each bar is 'd';
the width of the space between bars is 's';
the distance from the start of one group to the start of the
next group is 3*d + s = 1 unit on the x-scale;

Now we need to know the relationship of 's' to 'd': 3*d/s = 2;
Hence 3*d + 3*d/2 = 1 => d = 2/9 (so your 0.22 was spot-on).

How do we know that 3*d/s = 2? That's the default box.ratio value.
See what happens if you add box.ratio=3 (or whatever) to your call.

 -Peter Ehlers


Thanks in advance.
Walmes Zeviani, Lavras - MG, Brasil.
                                        
_________________________________________________________________

os.

dium=Tagline&utm_campaign=InfuseSocial
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Peter Ehlers
University of Calgary

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to