[R] barplot2, gap.barplot
Marc A. Rohling
marc at rohling-online.de
Thu Mar 1 14:56:25 CET 2007
Hello,
I try to handle a simple bar-plot, but it turns out to be not as simple
as I thought.
1) I have created a .dat-File, e.g. test.dat:
DATA DATA-SEM
2.2 0.32
6.2 1.30
12.7 1.61
48.6 3.08
4.1 0.86
4.5 0.32
1.5 1.13
1.2 1.08
The first row is the data represented by bars. The second row deals with
the Standard Error of Mean. The lines correspond to time-intervals of
experiments.
2) I now wrote this R-Script:
#=====BEGIN=====
# example.R
library(gdata)
library(gtools)
library(gmodels)
library(gplots)
library(plotrix)
data <- matrix(scan("./plot/example.dat", skip=1), ncol=2, nrow=8,
byrow=TRUE,
dimnames=list(c("1", "2", "3", "4", "5", "6", "7", "8"),c("DATA",
"DATA-SEM")))
conf_l <- data[, 1]
conf_u <- data[, 1] + data[, 2]
op <- par(no.readonly = TRUE)
par(lab=c(8,10,7))
barplot2(
height=data[, 1],
width=1,
space=1,
col='black',
border='black',
angle=0,
density=NULL,
ylim=c(-2,55),
xpd=FALSE,
axes=TRUE,
las=1,
ci.u=conf_u,
ci.l=conf_l,
plot.ci=TRUE,
ci.color="black",
ci.lty="solid",
ci.lwd=1,
horiz=FALSE,
main="Header",
ylab="",
xlab="\nduration of treatment",
plot.grid=TRUE)
par(op)
#====END=====
As you can see, because of the 4th bar (value > 45), the other bars look
a little bit tiny: there is too much white-space. What I need to handle
this problem is a function to insert a gap.
I tried to use gap.barplot, but unfortunately, it cannot handle any of
the parameters I need from the barplot2-function.
After days of missing effort, I am sick of this problem. Is there a
solution?
Thanks for your help,
Marc
More information about the R-help
mailing list