本文共 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结合可以帮助我们绘制所需的三角函数。 在本文中,我们将介绍一些三角函数的例子。
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()
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()
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()
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/