欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

如何使用 Python Matplotlib 绘制简单的正弦曲线

最编程 2024-04-22 08:33:31
...
# import matplotlib pyplot module. from matplotlib import pyplot as plt # import numpy module. import numpy as np # import python math module. import math # call the math.pi method to convert radians to angles. # get the x-axis value. x = np.arange(0, math.pi*2, 0.05) # calculate the y-axis value use the np.sin() method. y = np.sin(x) # plot the sine curve. plt.plot(x,y) # draw the x-axis and y-axis label. plt.xlabel("angle") plt.ylabel("sine") # draw the image title. plt.title('sine wave') # call the show() method to display the image. plt.show()