[R] axis in a normal plot

Marianne Promberger mpromber at psych.upenn.edu
Fri Sep 26 14:56:19 CEST 2008


On Friday, 26 September 2008, 10:49 (UTC+0200), Silje-Kristin Jensen wrote:
> Hi
> I have a small problem, I'm new in using R, so I hope you can help me...
> I'm running a logistic regression model and want to do a nice plot.
> The plot I have made is done a plot with the command jitter: 
> 
> plot(jitter(overto$age[overto$sex=="F"]),jitter(overto$neg.pos[overto$sex=="F"]),xlab="age",ylab="neg and pos")
> 
> my responsvariable is positive and negative (1 and 0) and my explanatory variable are age, year and sex.
> 
>  When I run my command plot the yaxis "decide" to make the axis with
>  the numbers: -0.2, 0.2, 0.6 and 1.
> What command can I use to change the axis so only 0 and 1 appear?


You need two steps.

in your plot() set yaxt="n" so that R doesn't draw any y axis.

Then, after plotting, you draw a custom y axis with axis()

x <- seq.int(0,1,0.2)
y <- x
plot(x,y, yaxt="n")
axis(2,at=c(0.2,0.6,1))

m.


> 
> I have tried ylim=c(0:1) that did not work, and I tried yrange 
> 
> Thanks
> 
>  
> 
> Silje
> 
>  
> 
> ?`?.??.???`?.??.???`?.? ><(((?>
> 
> Silje-Kristin Jensen
> 
> Norsk Polarinstitutt / Norwegian Polar Insitute
> Polarmilj?senteret
> N-9296 Troms?
> Phone: +47 95166782
> E-mail: silje at npolar.no <mailto:silje at npolar.no> 
> 
> JaP please don't print this e-mail unless you really need to
> 
>  
> 
> 	[[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.


-- 
Marianne Promberger
Graduate student in Psychology
http://www.psych.upenn.edu/~mpromber



More information about the R-help mailing list