tp3_solutions.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:TPs 作者: DataMiningP7 项目源码 文件源码
def ex2():
    x = np.linspace(-10, 10)

    # "--" = dashed line
    plt.plot(x, np.sin(x), "--", label="sinus")
    plt.plot(x, np.cos(x), label="cosinus")

    # Show the legend using the labels above
    plt.legend()

    # The trick here is we have to make another plot on top of the two others.
    pi2 = np.pi/2

    # Find B such that (-B * pi/2) >= -10 > ((-B-1) * pi/2), i.e. the
    # first multiple of pi/2 higher than -10.
    b = pi2*int(-10.0/pi2)

    # x2 is all multiples of pi/2 between -10 and 10.
    x2 = np.arange(b, 10, pi2)

    # "b." = blue dots
    plt.plot(x2, np.sin(x2), "b.")
    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号