1. 程式人生 > >畫四葉草

畫四葉草

# Import the module for plotting
# _*_ coding:utf-8 _*_

import numpy as np
import matplotlib.pyplot as plt

if __name__ == '__main__':
    a = 1
    t = np.linspace(-50,50,num=1000)
    p = a * np.cos(2*t)
    x = p * np.sin(t)
    y = p * np.cos(t)
    plt.figure(figsize=(4, 4), facecolor='w')
    plt.plot(x, y, 'r-', linewidth=0.5)
    plt.savefig('四葉草.jpg')
    plt.grid()
    plt.show()