mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-24 10:54:04 +08:00
fixed (#8770)
This commit is contained in:
parent
d51dd2ce17
commit
13f4cf899f
@ -1 +1 @@
|
||||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: stock_forecast"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy matplotlib"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "import gradio as gr\n", "\n", "\n", "def plot_forecast(final_year, companies, noise, show_legend, point_style):\n", " start_year = 2020\n", " x = np.arange(start_year, final_year + 1)\n", " year_count = x.shape[0]\n", " plt_format = ({\"cross\": \"X\", \"line\": \"-\", \"circle\": \"o--\"})[point_style]\n", " fig = plt.figure()\n", " ax = fig.add_subplot(111)\n", " for i, company in enumerate(companies):\n", " series = np.arange(0, year_count, dtype=float)\n", " series = series**2 * (i + 1)\n", " series += np.random.rand(year_count) * noise\n", " ax.plot(x, series, plt_format)\n", " if show_legend:\n", " plt.legend(companies)\n", " return fig\n", "\n", "\n", "demo = gr.Interface(\n", " plot_forecast,\n", " [\n", " gr.Radio([2025, 2030, 2035, 2040], label=\"Project to:\"),\n", " gr.CheckboxGroup([\"Google\", \"Microsoft\", \"Gradio\"], label=\"Company Selection\"),\n", " gr.Slider(1, 100, label=\"Noise Level\"),\n", " gr.Checkbox(label=\"Show Legend\"),\n", " gr.Dropdown([\"cross\", \"line\", \"circle\"], label=\"Style\"),\n", " ],\n", " gr.Plot(label=\"forecast\"),\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
||||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: stock_forecast"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy matplotlib"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "import gradio as gr\n", "\n", "\n", "def plot_forecast(final_year, companies, noise, show_legend, point_style):\n", " start_year = 2020\n", " x = np.arange(start_year, final_year + 1)\n", " year_count = x.shape[0]\n", " plt_format = ({\"cross\": \"X\", \"line\": \"-\", \"circle\": \"o--\"})[point_style]\n", " fig = plt.figure()\n", " ax = fig.add_subplot(111)\n", " for i, company in enumerate(companies):\n", " series = np.arange(0, year_count, dtype=float)\n", " series = series**2 * (i + 1)\n", " series += np.random.rand(year_count) * noise\n", " ax.plot(x, series, plt_format)\n", " if show_legend:\n", " plt.legend(companies)\n", " return fig\n", "\n", "\n", "demo = gr.Interface(\n", " plot_forecast,\n", " [\n", " gr.Radio([2025, 2030, 2035, 2040], label=\"Project to:\"),\n", " gr.CheckboxGroup([\"Google\", \"Microsoft\", \"Gradio\"], label=\"Company Selection\"),\n", " gr.Slider(1, 100, label=\"Noise Level\"),\n", " gr.Checkbox(label=\"Show Legend\"),\n", " gr.Dropdown([\"cross\", \"line\", \"circle\"], label=\"Style\"),\n", " ],\n", " gr.Plot(label=\"forecast\", format=\"png\"),\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
@ -30,7 +30,7 @@ demo = gr.Interface(
|
||||
gr.Checkbox(label="Show Legend"),
|
||||
gr.Dropdown(["cross", "line", "circle"], label="Style"),
|
||||
],
|
||||
gr.Plot(label="forecast"),
|
||||
gr.Plot(label="forecast", format="png"),
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user