Again me. I want to plot the numbers on the bars of a barplot. This can be done using hist function when setting the label argument true (i.e. data <- c(1,2,3,4) hist(data, labels=T) When I try this using barplot I get an error:> barplot(summary(data), labels=T)Error in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty axis.lty, : formal argument "labels" matched by multiple actual arguments In addition: Warning message: parameter "labels" couldn't be set in high-level plot() function How would I do this the R(ight)-way? Thanks, Bernd [[alternative HTML version deleted]]
Perhaps: x <- barplot(data, ylim=c(0, max(data)+1)) text(x,data+.2, data) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 25/10/2007, Bernd Jagla <baj2107@columbia.edu> wrote:> > Again me. > > > > I want to plot the numbers on the bars of a barplot. > > This can be done using hist function when setting the label argument true > (i.e. > > > > data <- c(1,2,3,4) > > hist(data, labels=T) > > > > When I try this using barplot I get an error: > > > > > barplot(summary(data), labels=T) > > Error in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty > axis.lty, : > > formal argument "labels" matched by multiple actual arguments > > In addition: Warning message: > > parameter "labels" couldn't be set in high-level plot() function > > > > How would I do this the R(ight)-way? > > > > Thanks, > > > > Bernd > > > [[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. >[[alternative HTML version deleted]]
On 10/25/07, Bernd Jagla <baj2107 at columbia.edu> wrote:> Again me. > > > > I want to plot the numbers on the bars of a barplot.This is usually a bad idea, as the size of the numbers will distort the shape of the bars, worsening perceptual accuracy. Do you want a table or a graph? Hadley -- http://had.co.nz/
I am using the following construct and so far I am OK with it... b<-barplot(data, ylim=c(0, max(data)+max(data)/20)) text(b,data+max(data)/30, data) Thanks, for the comments. -B |-----Original Message----- |From: hadley wickham [mailto:h.wickham at gmail.com] |Sent: Friday, October 26, 2007 11:47 AM |To: Bernd Jagla |Cc: r-help at r-project.org |Subject: Re: [R] ploting labels on barplot | |On 10/25/07, Bernd Jagla <baj2107 at columbia.edu> wrote: |> Again me. |> |> |> |> I want to plot the numbers on the bars of a barplot. | |This is usually a bad idea, as the size of the numbers will distort |the shape of the bars, worsening perceptual accuracy. Do you want a |table or a graph? | |Hadley | | |-- |http://had.co.nz/
Bernd Jagla wrote:> Again me. > > > > I want to plot the numbers on the bars of a barplot. > > This can be done using hist function when setting the label argument true > (i.e. > > > > data <- c(1,2,3,4) > > hist(data, labels=T) > > > > When I try this using barplot I get an error: > > > > >> barplot(summary(data), labels=T) > > > Error in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty > axis.lty, : > > formal argument "labels" matched by multiple actual arguments > > In addition: Warning message: > > parameter "labels" couldn't be set in high-level plot() function > >Hi Bernd, Try the "names.arg" argument in the "barp" function in plotrix. Jim