{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# 2D plotting\n",
    "\n",
    "Plot a basic 2D figure\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 18904 characters]",
      "text/plain": [
       "<Figure size 640x480 with 2 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# 创建一个随机数生成器实例（NumPy 推荐的新写法，可复现）\n",
    "rng = np.random.default_rng()\n",
    "\n",
    "# 生成 30×30 的二维数组，元素为 [0, 1) 区间的均匀随机值，模拟一幅“图像”\n",
    "image = rng.random((30, 30))\n",
    "\n",
    "# 将数组可视化为热力图，颜色映射使用 \"hot\"（黑→红→黄→白）\n",
    "plt.imshow(image, cmap=\"hot\")\n",
    "\n",
    "# 为图像添加右侧的颜色标尺，直观对应数值与颜色\n",
    "plt.colorbar()\n",
    "\n",
    "# 弹出窗口显示最终图形\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
