Python 繪製三角函數圖形
問題:「如何使用Python來繪製三角函數圖形呢?」
OK,在繪製圖形前,先來了解 Python 的數學程式庫(Mathematical functions)有哪些,從3.6.2的文件可看到如下:
所以可以用這三個數學函數來繪製。但是Python有比上面函式還好用的程式庫,叫做NumPy。使用NumPy可以快速產生繪圖資料。接下來要處理繪圖的功能,在 Python 的程式庫中,有Matplotlib可用,就用此程式庫來繪圖囉。
- 9.2.1. Number-theoretic and representation functions
- 9.2.2. Power and logarithmic functions
- 9.2.3. Trigonometric functions
- 9.2.4. Angular conversion
- 9.2.5. Hyperbolic functions
- 9.2.6. Special functions
- 9.2.7. Constants
在Trigonometric functions一節中可查到底下三個:
math.cos(x)- Return the cosine of x radians.
math.sin(x)- Return the sine of x radians.
math.tan(x)- Return the tangent of x radians.
範例程式:
輸出圖:
若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。
If you like this post, please click the ads on the blog or buy me a coffee. Thank you very much.
留言