zoukankan      html  css  js  c++  java
  • R语言 绘制正(余)弦图

    代码:

    x <- seq(-2*pi, 2*pi, 0.2)
    
    z <- pi*(-2:2)
    labels <- paste(-2:2,"π", sep="")
    # 绘制正弦曲线
    plot(x, sin(x), type="o", pch=4, col=2, ylim=c(-1.5, 1.5), xaxt="n", ann=F)
    # 添加余弦点图
    points(x, cos(x), pch=8, col=3)
    
    # 添加参考线
    abline(h=c(-1, 0,1), lty=2, col=8)
    # 设置图形标题和坐标轴标题
    title("sin & con", xlab="x", ylab="y",)
    axis(1, at=z, labels=labels)
    # 添加图例
    legend("bottomleft", inset=0.02, c("sin", "cos"), col=c(2, 3), 
           lty=c(1, -1), pch=c(4, 8), bg="gray95", cex=0.9,pt.cex=0.7, 
           seg.len=0.6, text.width=0.3)

    图形:

  • 相关阅读:
    内存对齐
    类和对象
    C++ 各种继承方式的类内存布局
    静态变量static
    程序内存布局
    String类
    C++与C的区别
    命名空间
    C
    D
  • 原文地址:https://www.cnblogs.com/shanger/p/12177998.html
Copyright © 2011-2022 走看看