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.
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')
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.
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.
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.
you can go to see 'xaxs'
in ?par
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With