Hello, I have am plotting a 0-4 ordinal scale (y-axis) against time (x-axis). Is there a way to label the values on the y-axis with the translation from the scale? That is, instead of having 0,1,2,3,4 on the y-axis, I would like "Never", "Once per month", "A few times per month", "A few times per week", "Everyday." Thanks, Mitch
You can use axis() to draw custom axes of many sorts. The examples under ?axis demonstrate how to not draw the default axes and how to make custom ones. Sarah On Wed, Oct 27, 2010 at 10:40 AM, Downey, Patrick <PDowney at urban.org> wrote:> Hello, > > I have am plotting a 0-4 ordinal scale (y-axis) against time (x-axis). Is > there a way to label the values on the y-axis with the translation from the > scale? That is, instead of having 0,1,2,3,4 on the y-axis, I would like > "Never", "Once per month", "A few times per month", "A few times per week", > "Everyday." > > Thanks, > Mitch >-- Sarah Goslee http://www.functionaldiversity.org
More specifically time=rnorm(20)+10 scale=rep(0:4,4) plot(time~scale,axes=F) axis(1,at=0:4,labels=c("Never", "Once per month", "A few times per month", "A few times per week","Everyday")) axis(2) Tom 2010/10/27 Sarah Goslee <sarah.goslee at gmail.com>:> You can use axis() to draw custom axes of many sorts. > The examples under ?axis demonstrate how to not draw the default > axes and how to make custom ones. > > Sarah > > On Wed, Oct 27, 2010 at 10:40 AM, Downey, Patrick <PDowney at urban.org> wrote: >> Hello, >> >> I have am plotting a 0-4 ordinal scale (y-axis) against time (x-axis). Is >> there a way to label the values on the y-axis with the translation from the >> scale? That is, instead of having 0,1,2,3,4 on the y-axis, I would like >> "Never", "Once per month", "A few times per month", "A few times per week", >> "Everyday." >> >> Thanks, >> Mitch >> > > > > -- > Sarah Goslee > http://www.functionaldiversity.org > > ______________________________________________ > 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. >
Oops. That was backwards plot(scale~time,axes=F) axis(2,at=0:4,labels=c("Never", "Once per month", "A few times per month", "A few times per week","Everyday")) axis(1) Tom 2010/10/27 Thomas Levine <thomas.levine at gmail.com>:> More specifically > > time=rnorm(20)+10 > scale=rep(0:4,4) > plot(time~scale,axes=F) > axis(1,at=0:4,labels=c("Never", "Once per month", "A few times per > month", "A few times per week","Everyday")) > axis(2) > > Tom > > 2010/10/27 Sarah Goslee <sarah.goslee at gmail.com>: >> You can use axis() to draw custom axes of many sorts. >> The examples under ?axis demonstrate how to not draw the default >> axes and how to make custom ones. >> >> Sarah >> >> On Wed, Oct 27, 2010 at 10:40 AM, Downey, Patrick <PDowney at urban.org> wrote: >>> Hello, >>> >>> I have am plotting a 0-4 ordinal scale (y-axis) against time (x-axis). Is >>> there a way to label the values on the y-axis with the translation from the >>> scale? That is, instead of having 0,1,2,3,4 on the y-axis, I would like >>> "Never", "Once per month", "A few times per month", "A few times per week", >>> "Everyday." >>> >>> Thanks, >>> Mitch >>> >> >> >> >> -- >> Sarah Goslee >> http://www.functionaldiversity.org >> >> ______________________________________________ >> 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. >> >
Thank you both. Using axis I have gotten exactly what I needed. Thanks, Mitch -----Original Message----- From: Thomas Levine [mailto:thomas.levine at gmail.com] Sent: Wednesday, October 27, 2010 2:34 PM To: Sarah Goslee Cc: Downey, Patrick; r-help at r-project.org Subject: Re: [R] Y Axis Labels Oops. That was backwards plot(scale~time,axes=F) axis(2,at=0:4,labels=c("Never", "Once per month", "A few times per month", "A few times per week","Everyday")) axis(1) Tom 2010/10/27 Thomas Levine <thomas.levine at gmail.com>:> More specifically > > time=rnorm(20)+10 > scale=rep(0:4,4) > plot(time~scale,axes=F) > axis(1,at=0:4,labels=c("Never", "Once per month", "A few times per > month", "A few times per week","Everyday")) > axis(2) > > Tom > > 2010/10/27 Sarah Goslee <sarah.goslee at gmail.com>: >> You can use axis() to draw custom axes of many sorts. >> The examples under ?axis demonstrate how to not draw the default axes >> and how to make custom ones. >> >> Sarah >> >> On Wed, Oct 27, 2010 at 10:40 AM, Downey, Patrick <PDowney at urban.org>wrote:>>> Hello, >>> >>> I have am plotting a 0-4 ordinal scale (y-axis) against time >>> (x-axis). Is there a way to label the values on the y-axis with the >>> translation from the scale? That is, instead of having 0,1,2,3,4 on >>> the y-axis, I would like "Never", "Once per month", "A few times per >>> month", "A few times per week", "Everyday." >>> >>> Thanks, >>> Mitch >>> >> >> >> >> -- >> Sarah Goslee >> http://www.functionaldiversity.org >> >> ______________________________________________ >> 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. >> >