{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 人工智能与机器学习-实验1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part.III Matplotlib绘图练习\n",
    "\n",
    "|学号       |姓名    |\n",
    "|----------|--------|\n",
    "|***REMOVED***|***REMOVED***|\n",
    "|2020113874|何一涛|"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. 曲线\n",
    "\n",
    "* 用蓝线绘制函数$𝑓(𝑥) = 𝑥^2−2𝑥+3$的图表，并在坐标(1,2)位置处标上一个红色的点\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 25332 characters]\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "x = np.linspace(-1, 3, 50)\n",
    "y = x**2 - 2*x + 3\n",
    "plt.plot(x, y, color='blue', linewidth=1.0)\n",
    "plt.scatter(1, 2, color='red')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. x-y图\n",
    "\n",
    "* 使用`np.linspace()`函数生成$t\\in [0, 2\\pi]$。\n",
    "* 给定$𝑥=16*sin⁡(𝑡)^3$和$𝑦=13*cos⁡(𝑡)−5*cos⁡(2𝑡)−2*cos⁡(3𝑡)−cos⁡(4𝑡)$，画出x-y图表，\n",
    "* 并给图标添加一个题目：Heart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 27508 characters]\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "t = np.linspace(0, 2*np.pi, 1000)\n",
    "x = 16*np.sin(t)**3\n",
    "y = 13*np.cos(t) - 5*np.cos(2*t) - 2*np.cos(3*t) - np.cos(4*t)\n",
    "plt.plot(x, y, color='red', linewidth=1.0)\n",
    "plt.title('Heart')\n",
    "plt.show()"
   ]
  }
 ],
 "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.10.7"
  },
  "vscode": {
   "interpreter": {
    "hash": "1f0d395e06aa83586067b19165efc9b683889967164248deef4bbf1fa27cfb00"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
