More Related Content
More from Alisha Smile (20)
Polar example
- 3. 極座標畫圖 (二)
195國立中央大學數學系
import pylab
# 直接使用 numpy 套件定義內容,且不需加上套件名稱
for numpy import *
# 角度範圍在 [0,2pi] 共 500 個點
a , b , n = 0 , 2*pi , 500
# 在 [a,b] 角度範圍產生 n 個平分角座標
angs = linspace(a,b,n)
# 對每個角度計算對應的 r 座標:
# r = exp(sin(ang)) – 2 cos(4 ang) + sin( (2*ang-pi)/24 )**5
rs = ( exp( sin(angs) ) – 2 * cos(4*angs) + sin( (2*angs-pi)/24 )**5 )
# 以圓弧座標畫圖
pylab.polar(angs,rs,lw=3)
# 塗成黃色
pylab.fill(angs,rs,color=’y’)
# 顯示標頭文字,紅色字
pylab.title( ”butterfly curve” , color=’r’ )
# 顯示圖形
pylab.show()