[R] plot - scaling axis

Jim Lemon
Tue, 24 Sep 2013 23:34:18 -0000

On 09/25/2013 03:25 AM, Hermann Norpois wrote:
> Hello,
>
> i attached an example with two plotted vectors, respectively. And you might
> see that the y and x axis are not the same scale (e.g. the third and the
> last plot).
>
> I would prefer them to be the same scale.
>
> A toy example:
>
> a<- c (1,2,3,4,5,6,9,20)
>> b<- c (0.2,0.4,0.6,1,0.5,1,1,0.1)
>> plot (a,b)
>
> I would like to a have a plot with the same scales for the y and x axis.
>
> Could you please give me a hint how it works.
> thanks
> Hermann
>
Hi Herman,
My guess is that you want the x and y scales to have the same length in
user units and perhaps even to have the same tick positions and values.
For the toy example:

a <- c (1,2,3,4,5,6,9,20)
b <- c (0.2,0.4,0.6,1,0.5,1,1,0.1)
plot (a,b,xlim=c(0,20),ylim=c(0,20))

Adding the solution that Bill provided:

plot (a,b,xlim=c(0,20),ylim=c(0,20),asp=1)

will ensure that the actual intervals on the x and y axes will be the same.

Jim