when i plot a barchart with 5 bars there is one bar pretty long and the others get smaller like (20, 80, 20, 5, 2) is there a way of displaying the number accoirding to each bar next to it? like in a bwplot the panel option N? -- View this message in context: http://r.789695.n4.nabble.com/Show-number-at-each-bar-in-barchart-tp2125438p2125438.html Sent from the R help mailing list archive at Nabble.com.
Try this. My appologies for not giving the attribution but I forget who wrote it. my.values=100000:100005 x <- barplot(my.values, ylim=c(0,110000)) text(x, my.values, my.values, pos=3) text(x, my.values, "wibble", pos=3) --- On Tue, 5/4/10, someone <vonhoffen at t-online.de> wrote:> From: someone <vonhoffen at t-online.de> > Subject: [R] Show number at each bar in barchart? > To: r-help at r-project.org > Received: Tuesday, May 4, 2010, 8:41 AM > > when i plot a barchart with 5 bars there is one bar pretty > long and the > others get smaller > like (20, 80, 20, 5, 2) > is there a way of displaying the number accoirding to each > bar next to it? > like in a bwplot the panel option N? > -- > View this message in context: http://r.789695.n4.nabble.com/Show-number-at-each-bar-in-barchart-tp2125438p2125438.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >
Hi someone, Try this: x <- c(20, 80, 20, 5, 2) b <- barplot(x, ylim = c(0, 85), las = 1) text(b, x+2, pch = x) HTH, Jorge On Tue, May 4, 2010 at 8:41 AM, someone <> wrote:> > when i plot a barchart with 5 bars there is one bar pretty long and the > others get smaller > like (20, 80, 20, 5, 2) > is there a way of displaying the number accoirding to each bar next to it? > like in a bwplot the panel option N? > -- > View this message in context: > http://r.789695.n4.nabble.com/Show-number-at-each-bar-in-barchart-tp2125438p2125438.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >[[alternative HTML version deleted]]
On May 4, 2010, at 9:40 AM, Jorge Ivan Velez wrote:> Hi someone, > > Try this: > > x <- c(20, 80, 20, 5, 2) > b <- barplot(x, ylim = c(0, 85), las = 1) > text(b, x+2, pch = x) >I suspect he wanted the "counts" in the label: x <- c(20, 80, 20, 5, 2) b <- barplot(x, ylim = c(0, 85), las = 1) text(b, x+2, labels=x, pch = x) ... although perhaps his specification by analogy to bwplot with panel option "N" was more meaningful to you that it was to me. I have no idea what that was supposed to suggest. -- David.> HTH, > Jorge > > On Tue, May 4, 2010 at 8:41 AM, someone <> wrote: > >> >> when i plot a barchart with 5 bars there is one bar pretty long and >> the >> others get smaller >> like (20, 80, 20, 5, 2) >> is there a way of displaying the number accoirding to each bar next >> to it? >> like in a bwplot the panel option N? >> -- >> View this message in context: >> http://r.789695.n4.nabble.com/Show-number-at-each-bar-in-barchart-tp2125438p2125438.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> R-help at 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. >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT
But before you go any further, please read some of Edward Tufte's material on clarity and simplicity in graphs. > On Tue, May 4, 2010 at 8:41 AM, someone <> wrote: > >> >> when i plot a barchart with 5 bars there is one bar pretty long and >> the >> others get smaller >> like (20, 80, 20, 5, 2) >> is there a way of displaying the number accoirding to each bar next >> to it?