diff --git a/content/_static/fractal.png b/content/_static/fractal.png
new file mode 100644
index 00000000..491636ef
Binary files /dev/null and b/content/_static/fractal.png differ
diff --git a/content/mooreslaw-tutorial.md b/content/mooreslaw-tutorial.md
index 18a13dcc..607846fa 100644
--- a/content/mooreslaw-tutorial.md
+++ b/content/mooreslaw-tutorial.md
@@ -331,19 +331,29 @@ https://fivethirtyeight.com elements. Change the matplotlib style with
transistor_count_predicted = np.exp(B) * np.exp(A * year)
transistor_Moores_law = Moores_law(year)
plt.style.use("fivethirtyeight")
-plt.semilogy(year, transistor_count, "s", label="MOS transistor count")
-plt.semilogy(year, transistor_count_predicted, label="linear regression")
+fig, ax = plt.subplots()
+ax.semilogy(year, transistor_count, "s", label="MOS transistor count")
+ax.semilogy(year, transistor_count_predicted, label="linear regression")
-plt.plot(year, transistor_Moores_law, label="Moore's Law")
-plt.title(
+ax.plot(year, transistor_Moores_law, label="Moore's Law")
+ax.set_title(
"MOS transistor count per microprocessor\n"
- + "every two years \n"
- + "Transistor count was x{:.2f} higher".format(np.exp(A * 2))
+ "every two years\n"
+ "Transistor count was x{:.2f} higher".format(np.exp(A * 2))
)
-plt.xlabel("year introduced")
-plt.legend(loc="center left", bbox_to_anchor=(1, 0.5))
-plt.ylabel("# of transistors\nper microprocessor")
+ax.legend(loc="center left", bbox_to_anchor=(1, 0.5))
+ax.set_xlabel("year introduced")
+ax.set_ylabel("# of transistors\nper microprocessor")
+```
+
+```{code-cell} ipython3
+---
+tags: [remove-cell]
+---
+# Create tutorial thumbnail
+from myst_nb import glue
+glue("thumb_mooreslaw", fig, display=False)
```
_A scatter plot of MOS transistor count per microprocessor every two years with a red line for the ordinary least squares prediction and an orange line for Moore's law._
diff --git a/content/tutorial-deep-learning-on-mnist.md b/content/tutorial-deep-learning-on-mnist.md
index 82aea978..74914218 100644
--- a/content/tutorial-deep-learning-on-mnist.md
+++ b/content/tutorial-deep-learning-on-mnist.md
@@ -178,9 +178,19 @@ num_examples = 5
seed = 147197952744
rng = np.random.default_rng(seed)
-fig, axes = plt.subplots(1, num_examples)
+fig, axes = plt.subplots(1, num_examples, figsize=(15, 3))
for sample, ax in zip(rng.choice(x_train, size=num_examples, replace=False), axes):
ax.imshow(sample.reshape(28, 28), cmap="gray")
+ ax.axis("off")
+```
+
+```{code-cell} ipython3
+---
+tags: [remove-cell]
+---
+# Create tutorial thumbnail
+from myst_nb import glue
+glue("thumb_mnist", fig, display=False)
```
_Above are five images taken from the MNIST training set. Various hand-drawn
diff --git a/content/tutorial-ma.md b/content/tutorial-ma.md
index f4aa9a98..69a1c490 100644
--- a/content/tutorial-ma.md
+++ b/content/tutorial-ma.md
@@ -278,16 +278,27 @@ This plot is not so readable since the lines seem to be over each other, so let'
available, and show the cubic fit for unavailable data, using this fit to compute an estimate to the observed number of cases on January 28th 2020, 7 days after the beginning of the records:
```{code-cell}
-plt.plot(t, china_total)
-plt.plot(t[china_total.mask], cubic_fit[china_total.mask], "--", color="orange")
-plt.plot(7, np.polyval(params, 7), "r*")
-plt.xticks([0, 7, 13], dates[[0, 7, 13]])
-plt.yticks([0, np.polyval(params, 7), 10000, 17500])
-plt.legend(["Mainland China", "Cubic estimate", "7 days after start"])
-plt.title(
- "COVID-19 cumulative cases from Jan 21 to Feb 3 2020 - Mainland China\n"
- "Cubic estimate for 7 days after start"
+fig, ax = plt.subplots()
+ax.plot(t, china_total)
+ax.plot(t[china_total.mask], cubic_fit[china_total.mask], "--", color="orange")
+ax.plot(7, np.polyval(params, 7), "r*")
+ax.set_xticks([0, 7, 13], dates[[0, 7, 13]])
+ax.set_yticks([0, np.polyval(params, 7), 10000, 17500])
+ax.legend(["Mainland China", "Cubic estimate", "7 days after start"])
+ax.set_title(
+ "COVID-19 cumulative cases from Jan 21 to Feb 3 2020\n"
+ "Mainland China Cubic estimate for 7 days after start"
)
+fig.tight_layout()
+```
+
+```{code-cell}
+---
+tags: [remove-cell]
+---
+# Create a thumbnail for the notebook
+from myst_nb import glue
+glue("thumb_ma", fig, display=False)
```
## In practice
diff --git a/content/tutorial-plotting-fractals.md b/content/tutorial-plotting-fractals.md
index e97b0cbe..e05f5851 100644
--- a/content/tutorial-plotting-fractals.md
+++ b/content/tutorial-plotting-fractals.md
@@ -16,7 +16,7 @@ kernelspec:
+++
-![Fractal picture](tutorial-plotting-fractals/fractal.png)
+![Fractal picture](_static/fractal.png)
+++
diff --git a/content/tutorial-plotting-fractals/fractal.png b/content/tutorial-plotting-fractals/fractal.png
deleted file mode 100644
index 5639e35e..00000000
Binary files a/content/tutorial-plotting-fractals/fractal.png and /dev/null differ
diff --git a/content/tutorial-static_equilibrium.md b/content/tutorial-static_equilibrium.md
index 34ccda01..51237d85 100644
--- a/content/tutorial-static_equilibrium.md
+++ b/content/tutorial-static_equilibrium.md
@@ -82,7 +82,7 @@ Quiver plots will be used to demonstrate [three dimensional vectors](https://mat
```{code-cell}
fig = plt.figure()
-d3 = fig.gca(projection="3d")
+d3 = fig.add_subplot(111, projection="3d")
d3.set_xlim(-1, 1)
d3.set_ylim(-1, 1)
@@ -96,7 +96,7 @@ d3.quiver(x, y, z, u, v, w, color="r", label="forceA")
u, v, w = forceB
d3.quiver(x, y, z, u, v, w, color="b", label="forceB")
-plt.legend()
+d3.legend()
plt.show()
```
@@ -113,7 +113,7 @@ You can plot it to see the result.
```{code-cell}
fig = plt.figure()
-d3 = fig.gca(projection="3d")
+d3 = fig.add_subplot(111, projection="3d")
d3.set_xlim(-1, 1)
d3.set_ylim(-1, 1)
@@ -132,6 +132,16 @@ plt.legend()
plt.show()
```
+```{code-cell} ipython3
+---
+tags: [remove-cell]
+---
+# Create thumbnail for tutorial
+from myst_nb import glue
+glue("thumb_static_eq", fig, display=False);
+```
+
+
However, the goal is equilibrium.
This means that you want your sum of forces to be $(0, 0, 0)$ or else your object will experience acceleration.
Therefore, there needs to be another force that counteracts the prior ones.
diff --git a/content/tutorial-svd.md b/content/tutorial-svd.md
index 3a0b58cd..d8daa23d 100644
--- a/content/tutorial-svd.md
+++ b/content/tutorial-svd.md
@@ -362,7 +362,8 @@ approx_img.shape
which is not the right shape for showing the image. Finally, reordering the axes back to our original shape of `(768, 1024, 3)`, we can see our approximation:
```{code-cell}
-plt.imshow(np.transpose(approx_img, (1, 2, 0)))
+fig, ax = plt.subplots()
+ax.imshow(np.transpose(approx_img, (1, 2, 0)))
plt.show()
```
@@ -382,3 +383,22 @@ terms of the norm of the difference. For more information, see *G. H. Golub and
- [SciPy Tutorial](https://docs.scipy.org/doc/scipy/reference/tutorial/index.html)
- [SciPy Lecture Notes](https://scipy-lectures.org)
- [A matlab, R, IDL, NumPy/SciPy dictionary](http://mathesaurus.sf.net/)
+
+```{code-cell} ipython3
+---
+tags: [remove-cell]
+---
+# Create notebook thumbnail
+from myst_nb import glue
+fig, ax = plt.subplots(1, 2)
+for a, im, ttl in zip(
+ ax,
+ (img_array, approx_img.transpose(1, 2, 0)),
+ ("Original", f"Reconstructed from\n{k} principal components"),
+):
+ a.imshow(im)
+ a.set_title(ttl)
+ a.axis("off")
+fig.tight_layout()
+glue("thumb_svd", fig, display=False)
+```
diff --git a/content/tutorial-x-ray-image-processing.md b/content/tutorial-x-ray-image-processing.md
index 54d59f4f..a2f65b4e 100644
--- a/content/tutorial-x-ray-image-processing.md
+++ b/content/tutorial-x-ray-image-processing.md
@@ -234,15 +234,27 @@ Display the original X-ray and the one with the Laplacian-Gaussian filter:
```{code-cell}
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 10))
-axes[0].set_title("Original")
-axes[0].imshow(xray_image, cmap="gray")
-axes[1].set_title("Laplacian-Gaussian (edges)")
-axes[1].imshow(xray_image_laplace_gaussian, cmap="gray")
-for i in axes:
- i.axis("off")
+for ax, img, title in zip(
+ axes,
+ (xray_image, xray_image_laplace_gaussian),
+ ("Original", "Laplacian-Gaussian (edges)"),
+):
+ ax.imshow(img, cmap="gray")
+ ax.set_title(title)
+ ax.axis("off")
+fig.tight_layout()
plt.show()
```
+```{code-cell} ipython3
+---
+tags: [remove-cell]
+---
+# Create tutorial thumbnail
+from myst_nb import glue
+glue("thumb_xray", fig, display=False)
+```
+
### The Gaussian gradient magnitude method
Another method for edge detection that can be useful is the
diff --git a/site/conf.py b/site/conf.py
index cd91edb5..39bb225b 100644
--- a/site/conf.py
+++ b/site/conf.py
@@ -26,6 +26,7 @@
extensions = [
'myst_nb',
'sphinx_copybutton',
+ 'sphinx_panels',
]
# Add any paths that contain templates here, relative to this directory.
diff --git a/site/contributing.md b/site/contributing.md
index 8985c56c..ef849c18 100644
--- a/site/contributing.md
+++ b/site/contributing.md
@@ -121,6 +121,39 @@ Remember to clear all outputs on your notebook before uploading it.
🎉 Wait for review!
+### Adding a tutorial thumbnail
+
+You may add a thumbnail to the front page of the tutorials site with the
+following procedure:
+
+1. In `index.md`, find the `panels` directive for your tutorial's category
+ (e.g. `NumPy Features` or `NumPy Applications`). The `panels` directive
+ begins with ````` ````{panels}```` `````.
+2. Add a new card to the bottom of the `panels`:
+
+ ```
+ ---
+
+ {doc}``
+
+ +++
+
+
+ ```
+
+ Where `` should be replaced with the path to the tutorial
+ (typically `content/`) and should be replaced
+ with the image you'd like to use as the thumbnail.
+
+ This can either be a static image, in which case traditional markdown image
+ syntax will work, or a figure generated during the execution of your
+ tutorial. In the latter case, use [the glue feature of myst-nb][myst_nb_glue].
+
+[myst_nb_glue]: https://myst-nb.readthedocs.io/en/latest/use/glue.html
+
+Don't worry if you get stuck - a reviewer/maintainer can help with the
+process of creating a thumbnail for your tutorial.
+
For more information about GitHub and its workflow, you can see
[this document][collab].
diff --git a/site/index.md b/site/index.md
index 6d6baa3a..4090c426 100644
--- a/site/index.md
+++ b/site/index.md
@@ -19,11 +19,9 @@ local copy of the `.ipynb` files, you can either
[clone this repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)
or use the download icon in the upper-right corner of each tutorial.
-## Content
-
```{toctree}
---
-maxdepth: 2
+hidden: true
---
features
@@ -31,6 +29,114 @@ applications
contributing
```
+## NumPy Features
+
+````{panels}
+
+{doc}`content/tutorial-svd`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+```{glue:} thumb_svd
+```
+
++++
+
+{badge}`numpy.linalg, badge-primary`
+
+---
+
+{doc}`content/tutorial-ma`
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+```{glue:} thumb_ma
+```
+
++++
+
+{badge}`numpy.ma, badge-primary`
+{badge}`numpy.polynomial, badge-primary`
+
+---
+
+{doc}`content/save-load-arrays`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+![Default thumbnail: NumPy logo](_static/numpylogo.svg)
+
++++
+
+{badge}`I/O, badge-primary`
+````
+
+## NumPy Applications
+
+````{panels}
+
+{doc}`content/mooreslaw-tutorial`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+```{glue:} thumb_mooreslaw
+```
+
+---
+
+{doc}`content/tutorial-deep-learning-on-mnist`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+```{glue:} thumb_mnist
+```
+
+---
+
+{doc}`content/tutorial-deep-reinforcement-learning-with-pong-from-pixels`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+![Diagram showing the component operations of reinforcement learning detailed
+in this tutorial](content/_static/tutorial-deep-reinforcement-learning-with-pong-from-pixels.png)
+
+---
+
+{doc}`content/tutorial-nlp-from-scratch`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+![Overview of the model architecture, showing a series of animated boxes.
+There are five identical boxes labeled A and receiving as input one of the
+words in the phrase "life's a box of chocolates". Each box is highlighted in
+turn, representing the memory blocks of the LSTM network as information passes
+through them, ultimately reaching a "Positive" output value.](content/_static/lstm.gif)
+
+---
+
+{doc}`content/tutorial-x-ray-image-processing`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+```{glue:} thumb_xray
+```
+
+---
+
+{doc}`content/tutorial-static_equilibrium`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+```{glue:} thumb_static_eq
+```
+
+---
+
+{doc}`content/tutorial-plotting-fractals`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+![An example of a fractal visualization from this tutorial](content/_static/fractal.png)
+
+---
+
+{doc}`content/tutorial-air-quality-analysis`
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+![A grid showing the India Gate in smog above and clear air below](content/_static/11-delhi-aqi.jpg)
+
+````
+
## Useful links and resources
The following links may be useful:
diff --git a/site/requirements.txt b/site/requirements.txt
index e040deba..1a249098 100644
--- a/site/requirements.txt
+++ b/site/requirements.txt
@@ -2,3 +2,4 @@ sphinx
myst-nb
sphinx-book-theme
sphinx-copybutton
+sphinx-panels