← 返回题库
初级

时间序列可视化

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve():
    import numpy as np
    import matplotlib.pyplot as plt
    np.random.seed(42)
    n = 200
    time = np.arange(n)
    trend = 0.05 * time
    seasonality = 10 * np.sin(2 * np.pi * time / 50)
    noise = np.random.normal(0, 3, n)
    ts = trend + seasonality + noise
    plt.figure(figsize=(12, 6))
    plt.plot(time, ts, 'b-', linewidth=1)
    plt.xlabel('时间')
    plt.ylabel('值')
    plt.title('时间序列数据')
    plt.grid(alpha=0.3)
    plt.show()
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码