博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 绘制三角函数_Python | 绘制三角函数
阅读量:2532 次
发布时间:2019-05-11

本文共 1544 字,大约阅读时间需要 5 分钟。

python 绘制三角函数

Trigonometry is one of the most important parts in engineering and many times, therefore in combination with NumPy can help us to plot our desired trigonometric functions. In this article, we are going to introduce a few examples of trig-functions.

三角学是工程学中最重要的部分之一,因此, 与NumPy结合可以帮助我们绘制所需的三角函数。 在本文中,我们将介绍一些三角函数的例子。

1)正弦函数 (1) Sine Function)

s = np.sin(t)fig, ax = plt.subplots()ax.plot(t, s)ax.set(xlabel='radians', ylabel='Sin(x)',       title='Sine Plot')ax.grid()plt.show()
Python | Plotting Trigonometric Functions (1)

2)余弦函数 (2) Cosine Function)

s = np.cos(t)fig, ax = plt.subplots()ax.plot(t, s)ax.set(xlabel='radians', ylabel='(cosx)',       title='Cosine Plot')ax.grid()plt.show()
Python | Plotting Trigonometric Functions (2)

3)切线函数 (3) Tangent Function)

t = np.arange(0.0, 1, 0.01)s = np.tan(t)fig, ax = plt.subplots()ax.plot(t, s)ax.set(xlabel='radians', ylabel='tan(x)',       title='Tangent Plot')ax.grid()plt.show()
Python | Plotting Trigonometric Functions (3)

用于绘制三角函数的Python代码 (Python code for plotting trigonometric functions)

import matplotlib.pyplot as pltimport numpy as np# Data for plottingt = np.arange(0.0, 24, 0.01)# Sine Plots = np.sin(t)fig, ax = plt.subplots()ax.plot(t, s)ax.set(xlabel='radians', ylabel='Sin(x)',       title='Sine Plot')ax.grid()plt.show()# Cosine Plots = np.cos(t)fig, ax = plt.subplots()ax.plot(t, s)ax.set(xlabel='radians', ylabel='(cosx)',       title='Cosine Plot')ax.grid()plt.show()# Tangent Plott = np.arange(0.0, 1, 0.01)s = np.tan(t)fig, ax = plt.subplots()ax.plot(t, s)ax.set(xlabel='radians', ylabel='tan(x)',       title='Tangent Plot')ax.grid()plt.show()

Output:

输出:

Output is as figure

翻译自:

python 绘制三角函数

转载地址:http://mttzd.baihongyu.com/

你可能感兴趣的文章
算法导论笔记(四)算法分析常用符号
查看>>
HttpClient读取数据乱码的解决方案
查看>>
如何使用FireBug插件查询元素的xPath属性
查看>>
ultraedit激活
查看>>
总结(6)--- python基础知识点小结(细全)
查看>>
亿级曝光品牌视频的幕后设定
查看>>
ARPA
查看>>
JSP开发模式
查看>>
我的Android进阶之旅------>Android嵌入图像InsetDrawable的使用方法
查看>>
Detours信息泄漏漏洞
查看>>
win32使用拖放文件
查看>>
Android 动态显示和隐藏软键盘
查看>>
raid5什么意思?怎样做raid5?raid5 几块硬盘?
查看>>
【转】how can i build fast
查看>>
接口测试-jmeter
查看>>
js便签笔记(5)——Dean Edwards大牛的跨浏览器AddEvent()设计(不知道是不是jQuery事件系统的原型)...
查看>>
重构wangEditor(web富文本编辑器),欢迎指正!
查看>>
null?对象?异常?到底应该如何返回错误信息
查看>>
django登录验证码操作
查看>>
(简单)华为Nova青春 WAS-AL00的USB调试模式在哪里开启的流程
查看>>