{
 "cells": [
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "\n",
    "# 绘制各指标小时均值变化趋势（标准化后）折线图\n",
    "for i, indicator in enumerate(indicators):\n",
    "    plt.plot(normalized.index, normalized[indicator], \n",
    "             marker='o',label=indicator, color=colors[i], linewidth=2)\n",
    "\n",
    "plt.title('各指标小时均值变化趋势（标准化后）', fontsize=14)\n",
    "plt.xlabel('小时', fontsize=12)\n",
    "plt.ylabel('标准化值', fontsize=12)\n",
    "plt.xticks(range(0, 24))\n",
    "plt.grid(alpha=0.3)\n",
    "plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left')\n",
    "plt.tight_layout()\n",
    "\n",
    "# 新增保存代码\n",
    "plt.savefig('images/hourly_trends_combined.png', dpi=300, bbox_inches='tight')  # 保存组合大图\n",
    "plt.show()\n",
    "\n",
    "# 新增保存子图代码\n",
    "for i, indicator in enumerate(indicators):\n",
    "    plt.figure(figsize=(8, 5))\n",
    "    plt.plot(normalized.index, normalized[indicator], \n",
    "             marker='o', color=colors[i], linewidth=2)\n",
    "    plt.title(f'{indicator}小时均值变化趋势（标准化后）')\n",
    "    plt.xlabel('小时')\n",
    "    plt.ylabel('标准化值')\n",
    "    plt.xticks(range(0, 24))\n",
    "    plt.grid(alpha=0.3)\n",
    "    plt.tight_layout()\n",
    "    plt.savefig(f'images/hourly_{indicator}.png', dpi=300)  # 保存单个指标子图\n",
    "    plt.close()"
   ],
   "id": "bc314c8f5ab643d4"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
