fourier_artist
fourier_artist copied to clipboard
用几个圆画任意图(傅里叶变换)
![]() |
![]() |
![]() |
![]() |
![]() |
|
![]() |
![]() |
![]() |
用几个圆画任意图
安装
pip install fourier_artist
示例:傅里叶变换画心
(随便画几个圈都是爱你的样子)
# 导入包
import numpy as np
import matplotlib.pyplot as plt
from fourier_artist.clean_data import get_data_from_func, clean_data
from fourier_artist.draw import draw
from matplotlib.animation import FuncAnimation
# 导入数据,这个X你可以自己制定画什么图
X = get_data_from_func()
# 清洗数据
X = clean_data(X)
fig, ax = plt.subplots(1, 1)
update_all = draw(X, fig, ax)
ani = FuncAnimation(fig, update_all, blit=True, interval=25, frames=len(X))
# ani.save('fourier.gif', writer='pillow')
plt.show()

draw everything you like
import numpy as np
import matplotlib.pyplot as plt
from fourier_artist.clean_data import get_data_from_func, clean_data
from fourier_artist.draw import draw
from matplotlib.animation import FuncAnimation
# 导入数据
X = get_data_from_func()
n = 100
t = np.linspace(0, 2 * np.pi, n)
x = (np.sin(t)) ** 2
y = (np.cos(t)) ** 2 + np.cos(t)
X = x + 1j * y
# 清洗数据
X = clean_data(X)
fig, ax = plt.subplots(1, 1)
update_all = draw(X, fig, ax)
ani = FuncAnimation(fig, update_all, blit=True, interval=25, frames=len(X))
# ani.save('demo2.gif', writer='pillow')
plt.show()








