{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 折线图\n", "\n", "使用 `pyplot` 创建一个折线图。当与 `ui.timer` 结合使用时,`push` 方法可以提供实时更新。\n", "\n", "- `n`: 线条的数量\n", "- `limit`: 每条线的最大数据点数(新点将替换最旧的点)\n", "- `update_every`: 只有在推送新数据多次后才更新图表,以节省CPU和带宽\n", "- `close`: 是否在退出上下文后关闭图形;如果你稍后想要更新它,请设置为 `False`(默认:`True`)\n", "- `kwargs`: 应该传递给 [`pyplot.figure`](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.figure.html) 的参数,如 `figsize``" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAUIAAADFCAYAAAAhb/tIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8g+/7EAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAiLklEQVR4nO3de1QTZ/oH8G8CJICaRBQIVEBURNeiIpY0tWe9EIWuXUXtsc2hih4rump1pa1KV6V12+KtpRZtPW232m23irRbu+ulLYKsVWJUvBQFOdalFgsBlRLwglzy/P7oj1lTAoImBpjnc84cyTvPTN43yXydZCYTCRERGGNMxKTO7gBjjDkbByFjTPQ4CBljosdByBgTPQ5CxpjocRAyxkSPg5AxJnquzu5AR2WxWFBaWooePXpAIpE4uzuMsTsQEWpqauDv7w+p9P735zgIW1BaWoqAgABnd4Mx1oqSkhL06dPnvtfDQdiCHj16APj1gVYoFE7uDWPsTtXV1QgICBC20/vFQdiCprfDCoWCg5CxDspeH1vxwRLGmOg9kCDcsmUL+vbtC3d3d2g0Ghw7dqzV+oyMDAwaNAju7u4ICwvDvn37rObPmjULEonEaoqJibGqqaysRFxcHBQKBVQqFebMmYPr16/bfWyMsc7P4UGYnp6OxMREJCcn4+TJkxg2bBiio6NRUVFhsz43Nxd6vR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xUKrVq0iX19fksvlFBUVRUVFRe163O6XPcfU9Bzampqe17y8PNJoNKRUKsnd3Z0GDx5Mb7zxhlWodKQx3bx5kyZMmEDe3t7k5uZGQUFBNHfuXCFYm9jjeeLrETLGRI/PI2SMiR4HIWNM9DgIGWOix0HIGBM9DkLGmOhxEDLGRI+DkDEmehyEjDHR4yBkjIkeByFjTPQ4CBljovd/VcBfwV4zCv0AAAAASUVORK5CYII=", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import math\n", "from datetime import datetime\n", "from nicegui import ui\n", "\n", "line_plot = ui.line_plot(n=2, limit=20, figsize=(3, 2), update_every=5) \\\n", " .with_legend(['sin', 'cos'], loc='upper center', ncol=2)\n", "\n", "def update_line_plot() -> None:\n", " now = datetime.now()\n", " x = now.timestamp()\n", " y1 = math.sin(x)\n", " y2 = math.cos(x)\n", " line_plot.push([now], [[y1], [y2]])\n", "\n", "line_updates = ui.timer(0.1, update_line_plot, active=False)\n", "line_checkbox = ui.checkbox('active').bind_value(line_updates, 'active')\n", "\n", "# ui.run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311", "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.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }