Hello,

I have got another problem.

I wrote a function which is able to create plots with different numbers of
bars.

In order to give them a similar look I determined the width of the bars
using the parameters

width=0.59

AND

ylim=c(0,10))

(see function below)

Now, this only works if I have just got up to 6 double bars. In the
following example it doesn't work because the bars for the line "Tab der
offe;9;11" are missing.

I would like to be able to create the plots up to more double bars (maybe 9
or so).

Does anyone know the ansers to this problem?
Thanks a lot in advance!!

Marion

function:

My .csv file " abb7ctreff " looks like this:

;bisher;in Zukunft
persönl Ges;55;24
andere Vera;45;23
Elternabende;39;26
Gespräche;18;11
persönl ;16;4
Schulunterr;14;9
Tag der offe;9;11

mw_g_2balk <- function(pfad="F:/04 Archiv/04 Programme/19
R_Syntaxe/Grafiken_Funktionen",abb="abb3",skala="prozent")
{
  setwd(pfad)
  postscript(file=paste(abb,".eps",sep=""))
  dat<-read.csv2(paste(abb,".csv",sep=""),header=T,check.names=F)
  dat1<-t(as.matrix(dat[,2:3],nrow=2))
  colnames(dat1)<-dat[,1]
  zehn<-seq(10,10000000,10)
  xmax<-max(dat1)
  ind<-min(which(zehn>=xmax))
  zehnind<-zehn[ind]
  ticks<-seq(0,zehnind,10)
  par(las=1)
  par(mar=c(5,4.5+0.3529412*(max(nchar(colnames(dat1)))-1),1,1))
  
barplot(dat1,width=0.59,horiz=T,col=c("steelblue4","lightsteelblue3"),border="NA",axes=F,beside=T,xlim=c(0,zehnind),cex.names=1.2,ylim=c(0,10))
  par(xpd=TRUE)
  abline(v = seq(10, zehnind, by = 10), col = "white")
  par(xpd=F)
  aa <- skala
  if(aa == "prozent")
  {axis(1,at=ticks,las=1,labels=paste(ticks,"%",sep=""))}
  else if (aa == "absolut")
  {axis(1,at=ticks,las=1,labels=ticks)}
  par(xpd=TRUE)

legend(0,-1.4,xjust=0,legend=colnames(dat)[-1],fill=c("steelblue4","lightsteelblue3"),bty="n",border="white",horiz=T,cex=1.2)
  dev.off()
}
mw_g_2balk(abb="abb7ctreff")

        [[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.

Reply via email to