简体   繁体   中英

Plot sine curve in R

How can I plot a generic sin curve in R? Based on the answer of this post , I tried:

x <- seq(0,pi,length.out=100)
y <- sin(x)
plot(x,y,type="l")

在此输入图像描述

Actually what I really would is this graph, produced by gnuplot :

plot sin(x) linestyle 1

在此输入图像描述

Furthermore, I would like to know why gnuplot produces a graph even if I do not assign any value to the variable x . Does it have a preassigned value or something else?

pi is just one half of a sine curve... add more pi so you will get more curves...

x <- seq(0,8*pi,length.out=100)
y <- sin(x)
plot(x,y,type="l")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM