s-news
[Top] [All Lists]

Re: No commands for barplots with error...

To: "Sung, Myong-Hee \(NCI\)" <sungm@mail.nih.gov>
Subject: Re: No commands for barplots with error...
From: "David M Smith" <dsmith@insightful.com>
Date: Tue, 27 Mar 2001 14:41:30 -0800
Cc: "S-News" <s-news@wubios.wustl.edu>
Importance: Normal
In-reply-to: <76D006EB9224D411B12B0008C7C59D960136FC64@nihexchange9.nih.gov>
Tip: instead of using lines() or segments() to add error bars, you could use
the function error.bar() with option add=T to add error bars to your
barplot.

If you are using barplot(), one tricky aspect is understanding the x
coordinates.  Using width=0.8 and space=0.25 ensures the right-hand edge of
each bar is at coordinates 1,2,3,... which makes adding the error bars
easier.
For example:

x <- 1:10
y <- runif(10, 5,10)
err <- runif(10,0,2)
barplot(y,width=0.8,space=0.25,ylim=c(0,13))
error.bar(x-0.4,y,err,add=T,gap=F)

As to why S-PLUS doesn't have a simple command for this: my opinion is that
there are many, many potential graphs that one may wish to create.  The GUI
tries to anticipate many of these, but when dealing with a language it's
better to provide the building blocks to create the graph you desire rather
than having a separate function for every possible graphic.

# David Smith

--
David M Smith <dsmith@insightful.com>
S-PLUS Product Marketing Manager, Insightful Corp, Seattle WA
Tel: +1 (206) 283 8802 x360
Fax: +1 (206) 283 0347

MathSoft is now Insightful!  See www.insightful.com for details.

> -----Original Message-----
> From: s-news-owner@lists.biostat.wustl.edu
> [mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Sung,
> Myong-Hee (NCI)
> Sent: Tuesday, March 27, 2001 14:08
> To: 'S-News'
> Subject: Re: [S] No commands for barplots with error...
>
>
> I thank Jim Pratt and Yuelin Li for sharing their ideas.
> The solution was to use the conventional barplots command and then use
> either lines
> or segments command to create the error line on top of the mean
> bars (using precalculated error values).
>
> I still wonder though why Splus doesn't have a simple command for this
> while the GUI version is provided...
>
> Myong-Hee  Sung
> ---------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu.  To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message:  unsubscribe s-news
>


<Prev in Thread] Current Thread [Next in Thread>