Re: [R] Help with setting the y-axis in a plot.

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Thu, 17 Mar 2011 23:19:11 -0700

Hi Caitlin,

You just need to set the ylim argument to plot (you already did but g_range is 0, 13 not 0, 15. So...

On Thu, Mar 17, 2011 at 10:49 PM, Caitlin <bioprogrammer_at_gmail.com> wrote:
> Hi all.
>
> I'm working on an assignment for a psychology class and I am not sure how to
> adjust the y-axis so it displays the range: 0, 5, 10, 15
>
> The code below is almost ideal:
>
> lsd = c(3, 5, 13)
> mar = c(1, 2, 3)
> g_range <- range(0, lsd, mar)
> plot(lsd, type="o", col="blue", ylim=c(0, 15),
> axes=FALSE, ann=FALSE)

This change to ylim should get you what you want.

Cheers,

Josh

> axis(1, at=1:3, lab=c("Low","Med","High"))
> axis(2, las=1, at=5*0:max(mar))
> box()
> lines(mar, type="o", pch=22, lty=2, col="red")
> title(main="The Effect of Drug Dosage and Type on the Number of
> Hallucinations", col.main="red", font.main=4)
> title(xlab="Dose", col.lab=rgb(0,0.5,0))
> title(ylab="Number of Hallucinations", col.lab=rgb(0,0.5,0))
>
> Thanks,
>
> ~Caitlin
>
>        [[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.
>

-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

______________________________________________
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.
Received on Fri 18 Mar 2011 - 06:23:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 Mar 2011 - 06:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive