Re: [R] bars' values on barplot

2007-08-06 Thread Greg Snow
Why do you feel the need to add the numbers to your barplot?

Occasionally this can be useful (and others have answered the question
on how to do it), but often when you feel the need to add numbers to a
graph you are really doing 2 things:

1. admitting the graph has failed
2. replacing the graph with a poorly laid out table (with a colorful but
distracting background).

If this is the case, then replacing the graph with a proper table is
probably the better option.

Just a couple of things to think about,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of akki
 Sent: Saturday, August 04, 2007 4:44 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] bars' values on barplot
 
 Hi,
 I need bars' values on barplot, and I don't know how I can 
 put it. I do my barplot as:
 
 data-read.table(/my_path/file.dat,header=T, sep=\t) 
 barplot(as.matrix(data),log=y,beside=TRUE,main=my_title, 
 xlab=x name, ylab=y name).
 
 How can I add the values on each bar?
 
 Thanks..
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch 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.


__
R-help@stat.math.ethz.ch 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.


Re: [R] bars' values on barplot

2007-08-05 Thread Mark Wardle
Akki,

1. Have a look at the result from a barplot() call.

From the help:
A numeric vector (or matrix, when beside = TRUE), say mp, giving the
coordinates of all the bar midpoints drawn, useful for adding to the
graph.

2. Have a look at the text() function that will annotate plots!


So, try this for starters:
my.values=1:5
x - barplot(my.values, ylim=c(0,7))
text(x, 0.4+my.values, wibble)

Hope this helps,

Best wishes,

Mark




On 04/08/07, akki [EMAIL PROTECTED] wrote:
 Hi,
 I need bars' values on barplot, and I don't know how I can put it. I do my
 barplot as:

 data-read.table(/my_path/file.dat,header=T, sep=\t)
 barplot(as.matrix(data),log=y,beside=TRUE,main=my_title, xlab=x name,
 ylab=y name).

 How can I add the values on each bar?

 Thanks..

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch 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.


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Clinical research fellow and specialist registrar, Neurology
Cardiff, UK

__
R-help@stat.math.ethz.ch 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.


Re: [R] bars' values on barplot

2007-08-05 Thread Mark Wardle
Much better. Thanks!

Mark

On 05/08/07, Adrian Dusa [EMAIL PROTECTED] wrote:
 On Sunday 05 August 2007, Mark Wardle wrote:
  [...]
  So, try this for starters:
  my.values=1:5
  x - barplot(my.values, ylim=c(0,7))
  text(x, 0.4+my.values, wibble)

 Mark, you could use the pos argument from ?par:

 my.values=10:15
 x - barplot(my.values, ylim=c(0,11))

 text(x, my.values, wibble, pos=3) # always does what you want, whereas:

 text(x, 0.4+my.values, wibble) # doesn't look very nice

 HTH,
 Adrian


 --
 Adrian Dusa
 Romanian Social Data Archive
 1, Schitu Magureanu Bd
 050025 Bucharest sector 5
 Romania
 Tel./Fax: +40 21 3126618 \
   +40 21 3120210 / int.101


 __
 This email has been scanned by the MessageLabs Email Security System.
 For more information please visit http://www.messagelabs.com/email
 __



-- 
Dr. Mark Wardle
Clinical research fellow and specialist registrar, Neurology
Cardiff, UK

__
R-help@stat.math.ethz.ch 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.


Re: [R] bars' values on barplot

2007-08-05 Thread Adrian Dusa
On Sunday 05 August 2007, Mark Wardle wrote:
 [...]
 So, try this for starters:
 my.values=1:5
 x - barplot(my.values, ylim=c(0,7))
 text(x, 0.4+my.values, wibble)

Mark, you could use the pos argument from ?par:

my.values=10:15
x - barplot(my.values, ylim=c(0,11))

text(x, my.values, wibble, pos=3) # always does what you want, whereas:

text(x, 0.4+my.values, wibble) # doesn't look very nice

HTH,
Adrian


-- 
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
  +40 21 3120210 / int.101

__
R-help@stat.math.ethz.ch 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.