Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R plotting why not starting from (0,0)?

Tags:

plot

r

I'm new to R programming and graphics. I'm trying to draw a graph but the (0,0) point is not at the right place. Can someone please tell me how to fix it? Thanks. enter image description here

Here's my code:

layout(matrix(c(0,0,0,0,0,
                0,1,3,2,0,
                0,0,0,0,0), nc = 5, byrow = TRUE),
       widths = c(lcm(2), 1, lcm(2), 1, lcm(2)),
       heights = c(lcm(2), 1, lcm(2)))
layout.show(3)
box("outer", lty = "dotted")
plot.new()
plot.window(xlim=c(-200,0),ylim=c(0,21))
box()
axis(1)
axis(4)
rect(-113,0,0,1,col='cyan')
like image 406
StarCub Avatar asked May 28 '11 03:05

StarCub


People also ask

How do I fix the scale of a plot in R?

To change the axis scales on a plot in base R Language, we can use the xlim() and ylim() functions. The xlim() and ylim() functions are convenience functions that set the limit of the x-axis and y-axis respectively.

What does YLIM mean in R?

Let's start with the ylim() function. It specifies the upper and lower limit of the y-axis. It is a fundamental function and can be used inside the ggplot() , plot() , and other plot functions as a parameter.

How do you show the value of a plot in R?

Method 1: Displaying only values using text() function in Plot. In this function user just need to call the text() function with the specified parameters into it after calling the plot() function in R language and this process will lead to a plot of the provided points by the user with the values in the plot.


1 Answers

you can go to see 'xaxs' in ?par

like image 79
Gary Li Avatar answered Oct 18 '22 05:10

Gary Li