Hello, I have made a barplot with some data and need a description below the x-axis. For example there are 20 values and I need a description "2003" for the first four values, then "2005" for the next eleven and "2006" for the last five values. I want the description below the x-axis-labels and above the x-axis title. Thanks, Christian
I think ?mtext should show you how to do what you want. On 11/09/06, Christian Oswald <c.oswald at matsci.uni-sb.de> wrote:> Hello, > > I have made a barplot with some data and need a description below the > x-axis. For example there are 20 values and I need a description "2003" > for the first four values, then "2005" for the next eleven and "2006" > for the last five values. > > I want the description below the x-axis-labels and above the x-axis title. > > Thanks, > > Christian > > ______________________________________________ > R-help at 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. >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP
Hi see ?mtext and its parameters side, line and at. HTH Petr On 11 Sep 2006 at 14:44, Christian Oswald wrote: Date sent: Mon, 11 Sep 2006 14:44:24 +0200 From: Christian Oswald <c.oswald at matsci.uni-sb.de> To: r-help at stat.math.ethz.ch Subject: [R] Description of x-axis Send reply to: c.oswald at matsci.uni-sb.de <mailto:r-help-request at stat.math.ethz.ch?subject=unsubscribe> <mailto:r-help-request at stat.math.ethz.ch?subject=subscribe>> Hello, > > I have made a barplot with some data and need a description below the > x-axis. For example there are 20 values and I need a description > "2003" for the first four values, then "2005" for the next eleven and > "2006" for the last five values. > > I want the description below the x-axis-labels and above the x-axis > title. > > Thanks, > > Christian > > ______________________________________________ > R-help at 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.Petr Pikal petr.pikal at precheza.cz
?mtext, also ?barplot since barplot returns midpoints of the bars. also ?rep for setting up a vector of repeating values. something like this: xLabels<-c(rep("2003",4),rep("2005",11),rep("2006",5)) midPoints<-barplot(<your original statements here>) mtext(xLabels,side=1,at=apply(midPoints,2,mean)) On 9/11/06, Christian Oswald <c.oswald at matsci.uni-sb.de> wrote:> Hello, > > I have made a barplot with some data and need a description below the > x-axis. For example there are 20 values and I need a description "2003" > for the first four values, then "2005" for the next eleven and "2006" > for the last five values. > > I want the description below the x-axis-labels and above the x-axis title. > > Thanks, > > Christian > > ______________________________________________ > R-help at 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. >
I have try to use mtext but I cannot plot the description below the x-axis. I have used mtext(xLabels,side=1,at=apply(midPoints,2,mean)) and the text appears between the axis and the names.arg But I wont it below the args, above the axis-labels. Christian ?mtext, also ?barplot since barplot returns midpoints of the bars. also ?rep for setting up a vector of repeating values. something like this: xLabels<-c(rep("2003",4),rep("2005",11),rep("2006",5)) midPoints<-barplot(<your original statements here>) mtext(xLabels,side=1,at=apply(midPoints,2,mean)) On 9/11/06, Christian Oswald <c.oswald at matsci.uni-sb.de <https://stat.ethz.ch/mailman/listinfo/r-help>> wrote:>/ Hello,/>/ />/ I have made a barplot with some data and need a description below the />/ x-axis. For example there are 20 values and I need a description "2003" />/ for the first four values, then "2005" for the next eleven and "2006" />/ for the last five values. />/ />/ I want the description below the x-axis-labels and above the x-axis title. />/ />/ Thanks, />/ />/ Christian />/ />/ ______________________________________________ />/ R-help at stat.math.ethz.ch <https://stat.ethz.ch/mailman/listinfo/r-help> 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. />
Add the option line=2 to mtext, like this: y <- 1:4 barplot(y,xlab="xaxis",names.arg=1:4) mtext("Mtext label",side=1,line=2) On 11/09/06, Christian Oswald <oswald at dhlaw.de> wrote:> I have try to use mtext but I cannot plot the description below the x-axis. > > I have used > mtext(xLabels,side=1,at=apply(midPoints,2,mean)) > and the text appears between the axis and the names.arg But I wont it below the args, above the axis-labels. > > Christian > > > > > > ?mtext, also ?barplot since barplot returns midpoints of the bars. > > also ?rep for setting up a vector of repeating values. > > something like this: > xLabels<-c(rep("2003",4),rep("2005",11),rep("2006",5)) > midPoints<-barplot(<your original statements here>) > mtext(xLabels,side=1,at=apply(midPoints,2,mean)) > > On 9/11/06, Christian Oswald <c.oswald at matsci.uni-sb.de <https://stat.ethz.ch/mailman/listinfo/r-help>> wrote: > >/ Hello, > />/ > />/ I have made a barplot with some data and need a description below the > />/ x-axis. For example there are 20 values and I need a description "2003" > />/ for the first four values, then "2005" for the next eleven and "2006" > />/ for the last five values. > />/ > />/ I want the description below the x-axis-labels and above the x-axis title. > />/ > />/ Thanks, > />/ > />/ Christian > />/ > />/ ______________________________________________ > />/ R-help at stat.math.ethz.ch <https://stat.ethz.ch/mailman/listinfo/r-help> 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 at 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. >-- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP -- ================================David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP
Thanks, that works but what are the coordinates of "at" in the y-direction? On which y-position mtext plots? Christian Jeff Bricker schrieb:> ?mtext, also ?barplot since barplot returns midpoints of the bars. > > also ?rep for setting up a vector of repeating values. > > something like this: > xLabels<-c(rep("2003",4),rep("2005",11),rep("2006",5)) > midPoints<-barplot(<your original statements here>) > mtext(xLabels,side=1,at=apply(midPoints,2,mean)) > > On 9/11/06, Christian Oswald <c.oswald at matsci.uni-sb.de> wrote: >> Hello, >> >> I have made a barplot with some data and need a description below the >> x-axis. For example there are 20 values and I need a description "2003" >> for the first four values, then "2005" for the next eleven and "2006" >> for the last five values. >> >> I want the description below the x-axis-labels and above the x-axis >> title. >> >> Thanks, >> >> Christian >> >> ______________________________________________ >> R-help at 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. >> > > >-- Diplom-Ingenieur Christian Oswald Universitaet des Saarlandes Lehrstuhl fuer Pulvertechnologie von Glas und Keramik Gebaude D2 2 D-66123 Saarbruecken Tel.: (+49) 0681/302-5249 Fax.: (+49) 0681/302-5227
Christian Oswald wrote:> Thanks, > that works but what are the coordinates of "at" in the y-direction? On > which y-position mtext plots?Please read ?mtext which tells you to use argument "line". Uwe Ligges> Christian > > > > > > > Jeff Bricker schrieb: >> ?mtext, also ?barplot since barplot returns midpoints of the bars. >> >> also ?rep for setting up a vector of repeating values. >> >> something like this: >> xLabels<-c(rep("2003",4),rep("2005",11),rep("2006",5)) >> midPoints<-barplot(<your original statements here>) >> mtext(xLabels,side=1,at=apply(midPoints,2,mean)) >> >> On 9/11/06, Christian Oswald <c.oswald at matsci.uni-sb.de> wrote: >>> Hello, >>> >>> I have made a barplot with some data and need a description below the >>> x-axis. For example there are 20 values and I need a description "2003" >>> for the first four values, then "2005" for the next eleven and "2006" >>> for the last five values. >>> >>> I want the description below the x-axis-labels and above the x-axis >>> title. >>> >>> Thanks, >>> >>> Christian >>> >>> ______________________________________________ >>> R-help at 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. >>> >> >> > >