pythonMatplotlib画⼼形线(极坐标直⾓坐标参数⽅程)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
matplotlib中subplotimport 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()

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。