From 71149813fc8f5ea5dcc3386cab22bc8fa3455b09 Mon Sep 17 00:00:00 2001 From: Tom van Woudenberg Date: Wed, 13 Mar 2024 11:42:10 +0100 Subject: [PATCH 1/2] Update widgets.ipynb --- book/features/widgets.ipynb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/book/features/widgets.ipynb b/book/features/widgets.ipynb index f63bbcc..e8e9fd5 100644 --- a/book/features/widgets.ipynb +++ b/book/features/widgets.ipynb @@ -10,17 +10,21 @@ "\n", "## `matplotlib` widgets\n", "When you'd like to use `ipywidgets` in combinations with a `matplotlib` figure, import the following packages:\n", + "\n", "```{python}\n", "import ipywidgets as widgets\n", "import micropip\n", "await micropip.install(\"ipympl\")\n", "```\n", + "\n", "Activate the correct output format:\n", + "\n", "```{python}\n", "%matplotlib widget\n", "```\n", "\n", "Write the code which generates your plot in a function:\n", + "\n", "```{python}\n", "fig = plt.figure() # Define the figure once\n", "ax = fig.add_subplot(1,1,1) # Define the axis once\n", @@ -30,7 +34,9 @@ " ax.plot(x,y) # Plot your actual data\n", " plt.draw() # Update the plot whenever this function is executed\n", "```\n", + "\n", "Initiate the widget:\n", + "\n", "```{python}\n", "input_slider = widgets.FloatSlider(value=0, min=0, max=10, step=1, description='Input variable:') # Defines a widget, more options than just FloatSlider\n", "widgets.interact(update_plot, input_variable_from_widget = input_slider);\n", From fb9d54915ca02ef4f17d70ab705dcb4ea13f1c43 Mon Sep 17 00:00:00 2001 From: Tom van Woudenberg Date: Wed, 13 Mar 2024 11:48:15 +0100 Subject: [PATCH 2/2] Update widgets.ipynb --- book/features/widgets.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/book/features/widgets.ipynb b/book/features/widgets.ipynb index e8e9fd5..361cb93 100644 --- a/book/features/widgets.ipynb +++ b/book/features/widgets.ipynb @@ -11,7 +11,7 @@ "## `matplotlib` widgets\n", "When you'd like to use `ipywidgets` in combinations with a `matplotlib` figure, import the following packages:\n", "\n", - "```{python}\n", + "```python\n", "import ipywidgets as widgets\n", "import micropip\n", "await micropip.install(\"ipympl\")\n", @@ -19,13 +19,13 @@ "\n", "Activate the correct output format:\n", "\n", - "```{python}\n", + "```python\n", "%matplotlib widget\n", "```\n", "\n", "Write the code which generates your plot in a function:\n", "\n", - "```{python}\n", + "```python\n", "fig = plt.figure() # Define the figure once\n", "ax = fig.add_subplot(1,1,1) # Define the axis once\n", "\n", @@ -37,7 +37,7 @@ "\n", "Initiate the widget:\n", "\n", - "```{python}\n", + "```python\n", "input_slider = widgets.FloatSlider(value=0, min=0, max=10, step=1, description='Input variable:') # Defines a widget, more options than just FloatSlider\n", "widgets.interact(update_plot, input_variable_from_widget = input_slider);\n", "```\n"