%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
def pcf_to_graph2(pcf, last):
start = 0 #定義域の左端
def here_function2(f, th):
r = f(th)
x = r * np.cos(th) # 極座標からの変換(x座標の抽出)
y = r * np.sin(th) # 極座標からの変換(y座標の抽出)
return x, y
th = np.arange(start,last, 0.01)
x, y = here_function2(pcf, th)
fig = plt.figure(figsize=(5,5)) # サイズを均等に
ax = fig.add_subplot(1,1,1)
#ax.set_aspect('equal')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['bottom'].set_position('zero')
ax.spines['left'].set_position('zero')
#ax.axis([-1.2,1.2,-1.2,1.2]) # コメントアウト
ax.grid() # グラフにグリッドを追加
ax.plot(x, y) # 描画
#ax.legend(bbox_to_anchor=(1, 1), loc='upper right', borderaxespad=0, fontsize=10) # ラベルの反映
plt.show()
last = 10 * np.pi # 周期の定義
n = 6
k = 5
def rose(th):
r = np.sin((n/k)*th)
return r
pcf_to_graph2(rose, last)
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme