简体   繁体   English

在R中绘制正弦曲线

[英]Plot sine curve in R

How can I plot a generic sin curve in R? 如何在R中绘制一般的sin曲线? 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 : 实际上我真正想要的是这个图,由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 . 此外,我想知道为什么gnuplot产生图形,即使我没有为变量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... pi只是正弦曲线的一半...添加更多pi以便您获得更多曲线......

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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