Hi @ all, I try to set a labeling on simple barchart. I do it with the text function. I want to see values of the x axis (BE_AKT$ammo) above the bars. When I try the following code, the values are shown, but not in the correct position. They should be labeled 0.08 above the bars. text(BE_AKT$ammo, BE_AKT$ammo + 0.08, label = BE_AKT$ammo, family="Calibri") Can somebody help me? Thank you very much! GeO -- View this message in context: http://r.789695.n4.nabble.com/Labeling-position-barchart-tp4649031.html Sent from the R help mailing list archive at Nabble.com.
You told us neither what you did, nor what was not as you expected. Nonetheless, try this example: x <- c(9, 5, 7) mybarplot <- barplot(x, ylim=c(0, 10)) text(mybarplot, x+.08, letters[1:3], pos=3) Sarah On Fri, Nov 9, 2012 at 6:33 AM, Geophagus <fh at retposto.net> wrote:> Hi @ all, > I try to set a labeling on simple barchart. > I do it with the text function. I want to see values of the x axis > (BE_AKT$ammo) above the bars. > When I try the following code, the values are shown, but not in the correct > position. > They should be labeled 0.08 above the bars. > > text(BE_AKT$ammo, BE_AKT$ammo + 0.08, label = BE_AKT$ammo, family="Calibri") > > Can somebody help me? > > Thank you very much! > GeO > >-- Sarah Goslee http://www.functionaldiversity.org
On 11/09/2012 10:33 PM, Geophagus wrote:> Hi @ all, > I try to set a labeling on simple barchart. > I do it with the text function. I want to see values of the x axis > (BE_AKT$ammo) above the bars. > When I try the following code, the values are shown, but not in the correct > position. > They should be labeled 0.08 above the bars. > > text(BE_AKT$ammo, BE_AKT$ammo + 0.08, label = BE_AKT$ammo, family="Calibri") >Hi GeO, At a rough guess, you want the _bottoms_ of the labels 0.08 user units above the tops of the bars. It is very unlikely that the values of BE_AKT$ammo (is that the 5.45 or the old 7.62?) will be valid for both x and y coordinates. What you probably want to do is collect the x positions from the initial plot: xpos<-barplot(...) then combine those with the y positions of your values for BE_AKT$ammo: text(xpos,BE_AKT$ammo + 0.08,label=BE_AKT$ammo,family="Calibri",pos=3) Notice that "pos=3" argument. This places the text above the coordinates. You can also do this with the "adj" argument. Jim
Hi and thanks a lot for your advices. Both work fine! Thanks GeoPhagUS -- View this message in context: http://r.789695.n4.nabble.com/Labeling-position-barchart-tp4649031p4649294.html Sent from the R help mailing list archive at Nabble.com.