2013-12-14 34 views
3

我正在學習R.到目前爲止,我已經能夠代表一些功能,但我不知道如何製作笛卡爾飛機。你如何在R中製造笛卡爾飛機?編碼一個R笛卡爾飛機

這裏是我的代碼:

num<-400 
a<-scan(n=1) 
x<-c(n=num) 
y<-c(n=num) 
for (i in 1:num) 
{ 
    x[i]=i 
    y[i]=x[i]^2 
} 
plot(x,y,type="l",col="red") 
title(main="Funzioni", col.main="blue", font.main=4) 

回答

3

好像你正在嘗試到400對它們的平方繪製的數字。你可以用做:

x = 1:400 
y = x^2 
plot(x, y, type="l", col="red") 
title(main="Funzioni", col.main="blue", font.main=4) 

包括對其他三個象限的一些(空)的空間和一些軸:

x = 1:400 
y = x^2 
plot(x, y, type="l", col="red", xlim=c(-400, 400), ylim=c(-16000, 16000)) 
abline(h=0) 
abline(v=0) 
title(main="Funzioni", col.main="blue", font.main=4)