[R] Changing the Y graph scale Maximum value.
Sundar Dorai-Raj
sundar.dorai-raj at PDF.COM
Tue Oct 19 23:11:10 CEST 2004
John Fisler wrote:
> Hello,
>
> I am new to R and have read the documents related to graphics but have
> not come across a description of how to change the maximum scale on a
> graph. Below is sample code that sets up a plot window with a 0 Minimum
> to 10 Maximum, X and Y coordinate system:
>
> x <- c(1,2,3,4,5,6,7,8,9,10)
> y <- c(1,1.5,2,2.5,3,3.5,4,4.5,5,5.5)
> plot(0:10, 0:10, type = "n" )# setting up coord. system
> points(x, y, col = "red", cex = 1.5)
>
> I now want to change the maximum Y axis scale to 6. I am using the
> 'points' function to plot 'x' and 'y' because my 'real' data is X and Y
> coordinate based. When I try to change the maximum Y scale to 6 as in
> the following code segment, I get the following error:
>
> plot(0:10, 0:6, type = "n" )# setting up coord. system
> Error in xy.coords(x, y, xlabel, ylabel, log) :
> x and y lengths differ
>
> How do I change the maximum Y scale to 6?
>
> Thanks,
>
> John Fisler
>
You should use ylim.
plot(0, 0, type = "n", xlim = c(0, 10), ylim = c(0, 6))
--sundar
More information about the R-help
mailing list