0
0

More than 3 years have passed since last update.

極方程式で花の曲線を描いてみた

Last updated at Posted at 2020-07-06

%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)

実行結果

1922077_李鳳桐_G2(データと数理II_6月26日課題5_2.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0