[R] how to specify the location of tick mark on x axies
jim holtman
jholtman at gmail.com
Sat Feb 16 18:00:11 CET 2008
I think what you want for your last statement is:
lines(pts, y2)
This uses the value of the tick marks to plot your line.
On Feb 16, 2008 6:53 AM, Xin <jasonshi510 at hotmail.com> wrote:
> hi,
>
> I did barplot. My data are:
>
> >y1<-c(13, 20, 22, 19, 10, 16, 8, 4, 3, 5, 7, 4, 0, 4, 4, 2, 4, 2, 2, 5, 1)
> >y2<-c(13, 23.29568698, 18.1385593, 14.97159795, 12.57640037, 10.65752306,
> 9.079421331, 7.7625489, 6.653641903, 5.714125735, 4.914645265,
> 4.232117758, 3.647980094, 3.147064034, 2.716830439, 2.346823055,
> 2.02826436, 1.753747752, 1.516997668, 1.31267921, 1.136244845
> )
> >x<-c(0, 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71,
> 76, 81, 86, 91, 96)
>
> >pts=barplot(y1,ylim=c(0,40),axes=TRUE,names.arg=x,border=TRUE,col="white")
> >axis(side=1,at=pts, labels=F, tick=T)
>
> x axis with tickmarks exactly at the middle of the bars
>
> Then I want to add line into the barplot. I used
>
> >lines(x,y2)
>
> But the data points of the line is plotted at the beggining of each category
> on x axis. I want to them plotted at the middle of each category.
>
> Can you help?
>
> Xin
>
>
>
> ----- Original Message -----
> From: "jim holtman" <jholtman at gmail.com>
> To: "Xin" <jasonshi510 at hotmail.com>
> Sent: Saturday, February 16, 2008 11:43 AM
> Subject: Re: [R] how to specify the location of tick mark on x axies
>
>
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> > Can you provide an example of what you are doing and what you want.
> >
> > On Feb 16, 2008 6:14 AM, Xin <jasonshi510 at hotmail.com> wrote:
> >> Dear:
> >>
> >> I want to plot barplot and let bar be in the middle of each x axis
> >> category.
> >>
> >> Do you have this experience?
> >>
> >> Many Thanks!
> >>
> >> Xin
> >> [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> 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.
> >>
> >
> >
> >
> > --
> > Jim Holtman
> > Cincinnati, OH
> > +1 513 646 9390
> >
> > What is the problem you are trying to solve?
> >
>
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list