用python画哟个炫酷的太极八卦动态图
时间: 2024-03-09 07:18:13 浏览: 46
好的,我可以给您提供一个用 Python 和 Matplotlib 库绘制太极八卦的动态图的代码。
```python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
# 画一个黑色的圆
theta = np.linspace(0, 2*np.pi, 1000)
x = np.cos(theta)
y = np.sin(theta)
ax.plot(x, y, color='black')
# 画出阴阳两部分的图案
yin = ax.fill_between(x, y, where=y<0, color='black')
yang = ax.fill_between(x, y, where=y>0, color='white')
# 添加动画效果
def animate(i):
yin.set_facecolor(plt.cm.binary(i/100))
yang.set_facecolor(plt.cm.binary(i/100+0.5))
return yin, yang
ani = animation.FuncAnimation(fig, animate, frames=100, interval=50, blit=True)
plt.axis('off')
plt.show()
```
运行上述代码,您将会看到一个动态的太极八卦图。您可以根据需要对代码进行修改,例如更改动画效果或调整图案大小。