1.极坐标
# -*- coding:utf8 -*-
# __author__ = 'wangxuhao'
# __file__ = 'Cardioid_polar'
import numpy as np
import matplotlib.pyplot as plt
theta = np.linspace(0, 2*np.pi, 1000)
y = np.pi * (1 - np.sin(theta))
graph = plt.subplot(111, polar=True)
graph.plot(theta, y,color='red', linewidth=2)
plt.show()
这个有一点胖了。。。
2.直角坐标的参数方程
# -*- coding:utf8 -*-
# __author__ = 'wangxuhao'
# __file__ = 'Cardioid'
import matplotlib.pyplot as plt
import numpy as np
import math
t = np.linspace(0, math.pi, 1000)
x = np.sin(t)
y = np.cos(t) + np.power(x, 2.0 / 3)
plt.plot(x, y, color='red', linewidth=2)
plt.plot(-x, y, color='red', linewidth=2)
plt.title("heart")
plt.ylim(-2, 2)
plt.xlim(-2, 2)
plt.show()