Van Gran
Van Gran

Reputation: 67

plot() in R: ylim range don't match the y axis range on graph

I wanted to plot this:

plot( 0, 0, type = "n",xlim =c(-3, 3), ylim =c(-5, 5), xlab = "x", ylab = "y" )

However, on the graph, it shows the y axes range is not c(-5, 5) but c(-4,4).

Upvotes: 2

Views: 1749

Answers (1)

akrun
akrun

Reputation: 887088

It is based on the tick labels, we can do

plot( 0, 0, type = "n",xlim =c(-3, 3), ylim =c(-4, 4), 
        xlab = "x", ylab = "y" , yaxt = 'n')
axis(2,  -4:4)

Upvotes: 4

Related Questions