Hi,
is there any way to change the width of the horizontal line of confidence intervals
in the barplot2 function in the plotrix package (independent of the width of the bars)?
example code:
library(plotrix)
# Example with confidence intervals and grid
hh <- t(VADeaths)[, 1]
mybarcol <- "gray20"
ci.l <- hh * 0.85
ci.u <- hh * 1.15
mp <- barplot2(hh, beside = TRUE,
col = c("lightblue", "mistyrose",
"lightcyan", "lavender"),
legend = colnames(VADeaths), ylim = c(0, 20),
main = "Death Rates in Virginia", font.main = 4,
sub = "Faked 95 percent error bars", col.sub = mybarcol,
cex.names = 1.5, plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u)
thanks!
change confidence interval line length in barplot2 (plotrix package)
6 messages · Martin Batholdy, Rolf Turner, David Winsemius +2 more
There does not appear to be any such function as barplot2 in
the current version (3.4-5) of the plotrix package. Moreover
I can find no reference to such a function in the "NEWS" for
plotrix.
cheers,
Rolf Turner
On 01/23/2013 07:28 AM, Martin Batholdy wrote:
Hi,
is there any way to change the width of the horizontal line of confidence intervals
in the barplot2 function in the plotrix package (independent of the width of the bars)?
example code:
library(plotrix)
# Example with confidence intervals and grid
hh <- t(VADeaths)[, 1]
mybarcol <- "gray20"
ci.l <- hh * 0.85
ci.u <- hh * 1.15
mp <- barplot2(hh, beside = TRUE,
col = c("lightblue", "mistyrose",
"lightcyan", "lavender"),
legend = colnames(VADeaths), ylim = c(0, 20),
main = "Death Rates in Virginia", font.main = 4,
sub = "Faked 95 percent error bars", col.sub = mybarcol,
cex.names = 1.5, plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u)
On Jan 22, 2013, at 10:28 AM, Martin Batholdy wrote:
Hi,
is there any way to change the width of the horizontal line of confidence intervals
in the barplot2 function in the plotrix package (independent of the width of the bars)?
example code:
library(plotrix)
# Example with confidence intervals and grid
hh <- t(VADeaths)[, 1]
mybarcol <- "gray20"
ci.l <- hh * 0.85
ci.u <- hh * 1.15
mp <- barplot2(hh, beside = TRUE,
col = c("lightblue", "mistyrose",
"lightcyan", "lavender"),
legend = colnames(VADeaths), ylim = c(0, 20),
main = "Death Rates in Virginia", font.main = 4,
sub = "Faked 95 percent error bars", col.sub = mybarcol,
cex.names = 1.5, plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u)
When I did an sos::findFn("barplot2") search to locate the "real" `barplot2` O alos noted in the same package (gplots) a function named `ooplot`. It calls itself an extenstion of barplot2 and has a ci.lwd argument. Might save you the time of doing what I thought might be needed, hacking te code.
David Winsemius Alameda, CA, USA
Ok, I have to apologize, I confused the packages. It's the function barplot2 from the gplots package!
It calls itself an extenstion of barplot2 and has a ci.lwd argument. Might save you the time of doing what I thought might be needed, hacking te code.
Unfortunately ci.lwd controls the thickness of the line but not the horizontal width.
On Jan 22, 2013, at 21:24 , David Winsemius <dwinsemius at comcast.net> wrote:
On Jan 22, 2013, at 10:28 AM, Martin Batholdy wrote:
Hi,
is there any way to change the width of the horizontal line of confidence intervals
in the barplot2 function in the plotrix package (independent of the width of the bars)?
example code:
library(plotrix)
# Example with confidence intervals and grid
hh <- t(VADeaths)[, 1]
mybarcol <- "gray20"
ci.l <- hh * 0.85
ci.u <- hh * 1.15
mp <- barplot2(hh, beside = TRUE,
col = c("lightblue", "mistyrose",
"lightcyan", "lavender"),
legend = colnames(VADeaths), ylim = c(0, 20),
main = "Death Rates in Virginia", font.main = 4,
sub = "Faked 95 percent error bars", col.sub = mybarcol,
cex.names = 1.5, plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u)
When I did an sos::findFn("barplot2") search to locate the "real" `barplot2` O alos noted in the same package (gplots) a function named `ooplot`. It calls itself an extenstion of barplot2 and has a ci.lwd argument. Might save you the time of doing what I thought might be needed, hacking te code.
--
David Winsemius
Alameda, CA, USA
Maybe a fortunate mistake. If you use the base graphics barplot(), you can
use plotCI() in plotrix to add the confidence intervals with control over
the width of the horizontal ends of the bars (if needed, the defaults are
much narrower):
out <- barplot(hh, beside = TRUE,
col = c("lightblue", "mistyrose", "lightcyan", "lavender"),
legend = colnames(VADeaths), ylim = c(0, 20),
main = "Death Rates in Virginia", font.main = 4,
sub = "Faked 95 percent error bars", col.sub = mybarcol,
cex.names = 1.5)
plotCI(out, hh, pch="", gap=0, ui=ci.u, li=ci.l, add=TRUE)
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of Martin Batholdy Sent: Tuesday, January 22, 2013 2:42 PM To: r-help at r-project.org Subject: Re: [R] change confidence interval line length in barplot2 (plotrix package) Ok, I have to apologize, I confused the packages. It's the function barplot2 from the gplots package!
It calls itself an extenstion of barplot2 and has a ci.lwd argument.
Might save you the time of doing what I thought might be needed, hacking te code. Unfortunately ci.lwd controls the thickness of the line but not the horizontal width. On Jan 22, 2013, at 21:24 , David Winsemius <dwinsemius at comcast.net> wrote:
On Jan 22, 2013, at 10:28 AM, Martin Batholdy wrote:
Hi, is there any way to change the width of the horizontal line of
confidence intervals
in the barplot2 function in the plotrix package (independent of the
width of the bars)?
example code:
library(plotrix)
# Example with confidence intervals and grid
hh <- t(VADeaths)[, 1]
mybarcol <- "gray20"
ci.l <- hh * 0.85
ci.u <- hh * 1.15
mp <- barplot2(hh, beside = TRUE,
col = c("lightblue", "mistyrose",
"lightcyan", "lavender"),
legend = colnames(VADeaths), ylim = c(0, 20),
main = "Death Rates in Virginia", font.main = 4,
sub = "Faked 95 percent error bars", col.sub = mybarcol,
cex.names = 1.5, plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u)
When I did an sos::findFn("barplot2") search to locate the "real"
`barplot2` O alos noted in the same package (gplots) a function named `ooplot`. It calls itself an extenstion of barplot2 and has a ci.lwd argument. Might save you the time of doing what I thought might be needed, hacking te code.
-- David Winsemius Alameda, CA, USA
______________________________________________ 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.
On Jan 22, 2013, at 2:41 PM, Martin Batholdy <batholdy at googlemail.com> wrote:
Ok, I have to apologize, I confused the packages. It's the function barplot2 from the gplots package!
It calls itself an extenstion of barplot2 and has a ci.lwd argument. Might save you the time of doing what I thought might be needed, hacking te code.
Unfortunately ci.lwd controls the thickness of the line but not the horizontal width.
barplot2() in gplots uses a hard coded width for the CI's, which is 50% of the bar width, so it is a consistent proportion. You could hack the code or simply use base graphics barplot() along with either ?segments or perhaps more easily, ?arrows, which would give you more flexibility. Compare: mp <- barplot(1:5) arrows(mp, 1:5 + 0.5, mp, 1:5 - 0.5, code = 3, angle = 90, length = 0.1) with: mp <- barplot(1:5) arrows(mp, 1:5 + 0.5, mp, 1:5 - 0.5, code = 3, angle = 90, length = 0.25) where the 'length' argument to arrows() defines the width of the upper and lower boundary lines. There are a fair number of other functions around that can add CI's to plots as well and a search of the archives should bear fruit. Regards, Marc Schwartz
On Jan 22, 2013, at 21:24 , David Winsemius <dwinsemius at comcast.net> wrote:
On Jan 22, 2013, at 10:28 AM, Martin Batholdy wrote:
Hi,
is there any way to change the width of the horizontal line of confidence intervals
in the barplot2 function in the plotrix package (independent of the width of the bars)?
example code:
library(plotrix)
# Example with confidence intervals and grid
hh <- t(VADeaths)[, 1]
mybarcol <- "gray20"
ci.l <- hh * 0.85
ci.u <- hh * 1.15
mp <- barplot2(hh, beside = TRUE,
col = c("lightblue", "mistyrose",
"lightcyan", "lavender"),
legend = colnames(VADeaths), ylim = c(0, 20),
main = "Death Rates in Virginia", font.main = 4,
sub = "Faked 95 percent error bars", col.sub = mybarcol,
cex.names = 1.5, plot.ci = TRUE, ci.l = ci.l, ci.u = ci.u)
When I did an sos::findFn("barplot2") search to locate the "real" `barplot2` O alos noted in the same package (gplots) a function named `ooplot`. It calls itself an extenstion of barplot2 and has a ci.lwd argument. Might save you the time of doing what I thought might be needed, hacking te code.
--
David Winsemius
Alameda, CA, USA