How to make a plot with axes at the centre in R

r
plot

#1

Hi all,

How can I make a plot in R with the X and Y axes in centre rather than at the bottom and the side respectively like shown below?

Thank you.


#2

one way to do it is use xlim and ylim

compare

plot(iris$Sepal.Length)
plot(iris$Sepal.Length,xlim=c(-150,150),ylim=c(-8,8))

note it does not draw axis but changes the box range

You can create custom axes using the axis( ) function.